Difference between revisions of "R/Extension"

From ScientificComputing
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
 
  R
 
  R
  
Packages can be installed by the '''packages.install()''' command (we use here the package "actuar" as an example)
+
Packages can be installed by the '''install.packages()''' command (we use here the package "actuar" as an example)
  
 
  install.packages("actuar")
 
  install.packages("actuar")
Line 26: Line 26:
 
  to install packages into?  (y/n)
 
  to install packages into?  (y/n)
  
After confirming this you will have to choose a download mirror. Versions 3.2 and newer have problems with HTTPS mirrors, therefore you should choose option "18", which uses a HTTP mirror for downloading the package sources. After choosing the download mirror, the package will be downloaded and installed. The locally installed R package is now ready to be used.
+
Afterwards the package will be downloaded and installed. The locally installed R package is now ready to be used.

Latest revision as of 13:25, 18 November 2020

Since R is highly extensible, users can work with several additional packages supplemented by R developers. You can display the list of already installed packages with the following R command in an interactive session:

installed.packages()

This should give you an overview on a common set of R packages. If you require an R package, which is not yet installed, you can either install it locally in your home directory, or you can contact us, such that we can install the package centrally if it is used by many cluster users.

For installing an R package locally, you first have to load the R module corresponding to the version for which it should be installed. After this you can launch R.

module load new gcc/4.8.2 r/3.3.0
R

Packages can be installed by the install.packages() command (we use here the package "actuar" as an example)

install.packages("actuar")

This command will cause a warning, since users do not have write access to the library directory of the corresponding R installation:

Warning in install.packages("actuar") :
  'lib = "/cluster/apps/r/3.3.0_openblas/lib64/R/library"' is not writable
Would you like to use a personal library instead?  (y/n)

When asked if you would like to use a personal library, confirm this by typing y. This will create a local library directory $HOME/R/x86_64-unknown-linux-gnu-library/3.3 where the package will be installed at a later stage. Next you will be asked if you like to install the package in your local library directory

Would you like to create a personal library
~/R/x86_64-unknown-linux-gnu-library/3.3
to install packages into?  (y/n)

Afterwards the package will be downloaded and installed. The locally installed R package is now ready to be used.