While I install my R package (for testing) it also re-installs all the dependencies (first time) that are already present on the system - r

I have a code to track objects in the images. This code uses few function from the package clue. So clue is already installed in my system. Now I have created a package using the same code.
My description file has following lines.
Depends: R (>= 3.4.3),
clue
Because clue is already installed, I thought it will not get installed again when I use install("mypackage"). But to my surprise it re-installed the package. I have tried this with other installed packages, too. When I give it as "depends" or "import", it re-installs the packages. I do not want to re-install the packages if they are already on my system. Is there a way to tell R package installer to avoid re-installing packages that exist on the user's system? Some of these packages are quite large and take a lot of time to install. In addition, I have installed some packages with binary source/dependency that required me to give path for several libraries.

You can just use
install.packages(..., dependencies = FALSE)
or if you use devtools::install:
install(..., dependencies = FALSE)

Related

R package listed on CRAN but not in available package

I want to install a package that is listed in https://cran.r-project.org/web/packages/available_packages_by_name.html as available in CRAN, but when I check in R the install packages menu or the available.packages() command, I can't see the package there.
Do I need to do something different to install those packages? Why aren't those packages available?
The packages I'm interested on are WikipediR ( https://cran.r-project.org/web/packages/WikipediR/index.html ), WikidataR and WikipediaR.
If it matters, I'm using R 2.15.0 in Windows XP.
See the documentation for ?available.packages...
By default, the return value includes only packages whose version and
OS requirements are met by the running version of R, and only gives
information on the latest versions of packages.
In other words... your R 2.15 is likely too old for the package you are looking to download.
You can try to download the package source manually add the package to the package library usually found somewhere like "win-library/2.15/" but like Cory mentioned it is likely that the older version of R does not support the package build.
The advice given so far is a bit incomplete although I do agree you need to update your R version if you want to use these packages. Looks like they don't need compilation so you might have been able to either install from a local copy or drop R code in, but critically they depend on httr which requires R 3.0.0 or above. They were released only relatively recently, so there will be no Windows binaries from back in 2012. (Your copy of R is from 30-Mar-2012.) Look in the DESCRIPTION file which is presented in a nice web format at the CRAN/package listing:
https://cran.r-project.org/web/packages/WikidataR/index.html
Imports: httr, jsonlite, WikipediR
Suggests: testthat, knitr, pageviews
# only one version of these two
https://cran.r-project.org/src/contrib/Archive/WikidataR/WikidataR_1.0.0.tar.gz
https://cran.r-project.org/src/contrib/Archive/WikipediaR/WikipediaR_1.0.tar.gz
# pick one of these
https://cran.r-project.org/src/contrib/Archive/WikipediR/

Package installation issues with R 3.1.0

My Fedora system (Fedora 20, all up to date) has just had R updated to version 3.1.0. Since then, I've had issues installing multiple packages. glmnet failed previously, and now I'm having trouble with treemap. More specifically, I get an error during treemap installation that httpuv has zero exit status.
I never had issues with the previous version of R. Any reason this version should have such problems??
There could be many causes to do with your OS, version, permissions, other installed packages/software, etc, etc. Without seeing the full error message it's hard to know.
One possibility specific to httpuv is root privileges. I've noticed a few threads on various forums when searching for installation errors with this package and Linux, many of them mentioning root v. non-root issues. In another case, libuv needed to be upgraded.
I encounter package installation problems daily and I have some more general work-arounds as well. Hopefully one of these will solve your problem.
Install the package from source
download.file(url="http://cran.r-project.org/src/contrib/httpuv_1.3.0.tar.gz", destfile = "httpuv.tar.gz")
install.packages("httpuv.tar.gz", type = "source", repos = NULL)
Install using devtools via GitHub if the package supports it
Install RTools and re-try your package installation
Install an older version of the package
If those above do not work, then I dig deeper by referring to advice given to me by a VP of IT in my company. These comments were made in reference to frequent package installation problems I encountered when switching from Windows to Solaris:
There are two types of install/make problems. Missing .h files
and/or missing .so/.a libs. The reason for these are multiple:
1.- the package that delivers these is not installed. This means that those files cannot be found anywhere in the /usr tree. Solution is
install right package, make sure the files are there
2.- the includes are not found by the install configurator. This means some environment variable or install option is not properly set (this
is our case for RODBC). Figuring out which variable to set is
challenging without looking at the package documentation [fortunately, documentation is not hard to find!]
3.- the libs are not in the LD_LIBRARY_PATH, easy to fix.
4.- There is a deeper compile/link error, meaning the package is not compatible with the rest of the sw, or has not been properly ported.

Error: "Package not available" for a package that should be current [duplicate]

I have been using the "stats" package in R 3.0.1 without any problems . But today i deleted the "stats" folder from the R library location and now I can't install it any more. I tried doing the same thing with other packages but I could install everything except "stats"
install.packages("stats", dep = TRUE, repos="http://cran.cs.wwu.edu")
## Installing package into ‘%Default R Lib Installation Path%’
## (as ‘lib’ is unspecified)
## Warning in install.packages : package ‘stats’ is not available (for R version 3.0.1)
I also tried downloading it from other sources like "http://cran.ma.imperial.ac.uk/" but nothing works . Any ideas?
(Since SO is nagging me not to continue the comment thread, I will post an answer.)
I believe that this problem will apply to any base package (but not to those installed from repositories, and probably not to Recommended packages): I am deeply skeptical that stats is the only package. It should occur for any of the packages in this list:
rownames(subset(as.data.frame(installed.packages()),Priority=="base"))
I'm sure it's theoretically possible to re-install a base package from scratch, but it will be much easier to re-install R. At a guess, it would take me about 15 minutes to re-install R, and I would feel lucky if I figured out how to re-install a base package on its own in less than an hour.
I'm pretty sure that re-installing R will not affect previously-installed packages: see e.g. http://cran.r-project.org/bin/windows/base/rw-FAQ.html#How-do-I-UNinstall-R_003f; that link is about uninstalling rather than re-installing, but this seems relevant:
Uninstalling R only removes files from the initial installation, not (for example) packages you have installed or updated.
Other choices would be
create another identical installation of R (on another machine, or in a non-default location); locate the relevant directories in your new installation and copy them over to your existing installation.
restore the relevant directories from your backup.
PS: obviously if you are doing this on a client's machine it would be a good idea to test my advice first ...
What worked for me was to copy the entire package folder from another to my R.home() directory.

How to convert R package and dependencies to debian packages?

I need to install R packages in several nodes (10+) in AWS.
I wont be able to open R shell in each and do install.packages("foo")
This will be done using a configuration management tool like Puppet and it'll be easier if i can do an apt-get installation of R packages automatically.
I found a list of R debian packages here:
http://cran.cnr.berkeley.edu/bin/linux/ubuntu/lucid/
But it does not contain all the packages that i need.
Is there a way to convert any R package and it's internal dependencies to a Debian package similar to the approach used in creating r-cran-*.deb?
Have you looked at http://debian-r.debian.net/ ?
All CRAN (and many other) packages already packaged
You can install packages without starting the R console. You can download the tar.gz packages from the cran website. For example here is the tar.gz for the randomForest package: http://cran.r-project.org/src/contrib/randomForest_4.6-7.tar.gz
R CMD INSTALL ${package}.tar.gz
The cran2deb project claims to do exactly this, turning an R package into a Debian package and noting the correct dependencies.
I haven't used it myself yet.

How do I reinstall a base-R package (e.g., stats, graphics, utils, etc.)?

I have been using the "stats" package in R 3.0.1 without any problems . But today i deleted the "stats" folder from the R library location and now I can't install it any more. I tried doing the same thing with other packages but I could install everything except "stats"
install.packages("stats", dep = TRUE, repos="http://cran.cs.wwu.edu")
## Installing package into ‘%Default R Lib Installation Path%’
## (as ‘lib’ is unspecified)
## Warning in install.packages : package ‘stats’ is not available (for R version 3.0.1)
I also tried downloading it from other sources like "http://cran.ma.imperial.ac.uk/" but nothing works . Any ideas?
(Since SO is nagging me not to continue the comment thread, I will post an answer.)
I believe that this problem will apply to any base package (but not to those installed from repositories, and probably not to Recommended packages): I am deeply skeptical that stats is the only package. It should occur for any of the packages in this list:
rownames(subset(as.data.frame(installed.packages()),Priority=="base"))
I'm sure it's theoretically possible to re-install a base package from scratch, but it will be much easier to re-install R. At a guess, it would take me about 15 minutes to re-install R, and I would feel lucky if I figured out how to re-install a base package on its own in less than an hour.
I'm pretty sure that re-installing R will not affect previously-installed packages: see e.g. http://cran.r-project.org/bin/windows/base/rw-FAQ.html#How-do-I-UNinstall-R_003f; that link is about uninstalling rather than re-installing, but this seems relevant:
Uninstalling R only removes files from the initial installation, not (for example) packages you have installed or updated.
Other choices would be
create another identical installation of R (on another machine, or in a non-default location); locate the relevant directories in your new installation and copy them over to your existing installation.
restore the relevant directories from your backup.
PS: obviously if you are doing this on a client's machine it would be a good idea to test my advice first ...
What worked for me was to copy the entire package folder from another to my R.home() directory.

Resources