Installing all CRAN packages that are not already installed?

r install package if not installed
r check if a package is installed
r install package command line
how to install prob package in r
how to install r packages in linux
install multiple packages in r
install.packages dependencies
r-project package install

The following R commands will install all CRAN packages:

availablePackages <- available.packages()[,1]

And the following command will list all installed packages:

installedPackages <- .packages(all.available = TRUE)

My question is: How do I instruct R to install all CRAN packages that are not already installed?

Frankly, I think it's painstaking job... it would last for days, even weeks (depending on resources), but here's the code (I just enjoy doing trivial things):

# get names of installed packages
packs <- installed.packages()
exc <- names(packs[,'Package'])

# get available package names
av <- names(available.packages()[,1])

# create loooong string
ins <- av[!av %in% exc]

I still don't get why you're doing this, but, hey... some things are just not meant to be.... What wonders me the most is the fact that you've already answered your own question! You got what you needed, and it's just up to you to put things together... Are we missing the point? Did you have something else in mind?!?

An efficient way to install and load R packages, Once the package is installed, you must load the package and only after it has been Reinstalling all packages every time I opened my script or R Markdown it checks whether a package is already installed or not, and then install only the  However, once you switch to your local environment and use the `install.packages()` command to get the package, you may realize that you can't install the package locally. The most plausible reason is that it is not hosted on CRAN. CRAN (Comprehensive R Archive Network) has very strict requirements, which can make listing a package a slow process.

1) Why would you want to do that? There are over 3500 (as of Feb 2012) of them?

2) Did you look at CRAN Task Views and the ctv package that allows you to install packages from a given task?

3) You bold-face question is a simple indexing query you can do by hand (and besides that, also see help(sets))

R> available <- LETTERS                  # a simple set
R> installed <- LETTERS[c(1:10, 15:26)]  # a simple subset
R> available[ ! available %in% installed ]
[1] "K" "L" "M" "N"

Edit: in response to your follow-up:

a) If a package does not pass 'R CMD check' on Linux and Windows, it does not get uploaded to CRAN. So that job is done.

b) Getting all depends at your end is work too as you will see. We did it for cran2deb which is at (which does full-blown Debian package building which is more than just installing). We get about 2050 out of 2150 packages built. There are a few we refuse to build because of license, a few we cannot because of missing headers or libs and a few we cannot build because they need e.g. BioConductor packages.

R Packages: A Beginner's Guide, A repository is a place where packages are located so you can install them from it​. Github : although this is not R specific, Github is probably the most that everything went well and the package was successfully installed. A missing value and suppressUpdates=FALSE updates installed packages, perhaps also installing Biobase, IRanges, and AnnotationDbi if they are not already installed. Package names containing a ‘/’ are treated as github repositories and installed using the install_github() function of the remotes package. suppressUpdates: logical(1) or

type this command and then all packages will be installed automatically:


How do I reinstall my packages for R 4.0 when many of them came , My experiments with R have led me to install several packages from Github: data frame of all installed packages local_pkgs <- installed.packages() This also applies when there is no version of a package on CRAN. Within R, using the install.packages function always attempts to install the latest version of the requested package available on CRAN: R> install.packages("arules") If the arules package depends upon other packages that are not already installed locally, the R installer automatically downloads and installs those required packages. This is a

Better if you use:


call the function and check if required package is installed:


install.packages function, Download and install packages from CRAN-like repositories or from local files. In all of these, "LinkingTo" is omitted for binary packages. If lib is omitted or is of length one and is not a (group) writable directory, in interactive use the code  In order to use a package, it needs to be installed on your computer by running install.packages("name_of_package") (do not forget "" around the name of the package, otherwise, R will look for an object saved under that name!). Once the package is installed, you must load the package and only after it has been loaded you can use all the

I've tested this and it works

installedPackages=.packages(all.available = TRUE)
missedPackages<-setdiff(availablePackages, installedPackages)
for (i in 1:length(missedPackages))
pkgName <- missedPackages[i]


R Installation and Administration, and all those it depends on (in any way) that are not already installed, use e.g.. > install.packages("Rcmdr", dependencies  Compare Installed Packages with CRAN-like Repositories. old.packages indicates packages which have a (suitable) later version on the repositories whereas update.packages offers to download and install such packages. new.packages looks for (suitable) packages on the repositories that are not already installed, and optionally offers them for installation.

An efficient way to install and load R packages, Discover also a more efficient way to install and load R packages in R and I could not remember which packages were already installed on which machine. Reinstalling all packages every time I opened my script or R  Check if packages are installed (and install if not) in R Say you have an R script that you share with others. You may not be sure that each user has installed all the packages the script will require. Using install.packages () would be unnessary for users who already have the packages and simply need to load them.

A Installing R and packages, Much of the ease of installing R its add-on packages is thanks to the CRAN infrastructure. This does not mean that there are no bugs in published R packages, but it Homebrew is a package manager for the Mac which lets you install and First, run this command (and all following commands) in the Ubuntu terminal. I've just installed the R 3.5 version and need to access all the hundreds of packages I currently have in the 3.4 folder. RStudio suggests "On most single-user systems (Mac, Windows, and Linux), when you upgrade to a new minor version of R (like 3.3.0 to 3.4.0), R will not find the packages, you will need to reinstall your R packages.

R - Packages, By default, R installs a set of packages during installation. Other packages which are already installed have to be loaded explicitly to be All the packages available in R language are listed at R Packages. You also need to load a package that is already installed previously but not available in the current environment. I can't load "psyc" on freshly installed Rstduio. Xcode tools are present. Tried mirror repo to no avail.Any help will be appreciated. here is what i get: > install.packages("psych") also installing the dependency ‘mnormt’ There is a binary version available but the source version is later: binary source needs_compilation mnormt 1.5-7 2.0.0 TRUE Do you want to install from sources the