Packages

Many libraries (or packages) are available for R 1 and more than 6500 have been uploaded to the CRAN website. If you are looking for a specific function, it is very likely that somebody has already developed a package and uploaded it to the CRAN website. It can be difficult to know what package to use and often many packages are available for the same task. Some packages (such as for example the survival package) have become the standard whilst others are relatively unknown. An internet search may help to decide on the most appropriate package to use for your task. Always read and download the accompanying reference manual (PDF) from the CRAN website for a complete reference to the package / function.

Installation of packages:

In JGR / Deducer 2;3, packages can be installed with the Package Installer available in the menu. After selecting a suitable CRAN mirror, just enter the first letter of the package, go down the list, select the package, select install and installation should commence.

RStudio 4 also has a package installer under Tools in the menu.

Alternatively, it is possible to enter the installation command directly into the console. For example to install the survival package 5 for the creation of survival curves:

install.packages(“survival”)

Using packages:

In JGR / Deducer, packages can be made available with Package Manager available from the menu. Selecting ‘loaded’ will load the package, or selecting ‘default’ will make sure the package is installed every time JGR / Deducer is started.

Alternatively, the package can be loaded from the console. For example, to load the survival package, type:

library(survival)

in the console.

Getting help:

The most comprehensive reference to the package can be downloaded from the CRAN website. For example, the PDF file containing the reference manual for  survival package can be downloaded from here:

http://cran.r-project.org/

  • Select packages from the menu on the left
  • Select Table of available package, sorted by name from the main window
  • From the top of the screen select S
  • Scroll down to survival and select it
  • Under Reference manual: select survival.pdf
    The reference manual should now available for download.

Further help can also be obtained by typing:

??survival

in the console. This should open up a help window with further information and examples on how to use the code.

Updating packages:

Packages are not updated automatically and this has to be done manually. To update a package in R:

update.packages(“survival”)

Or to update all packages:

update.packages()

Enter y for each package that requires updating.

It is not possible to update a package from within itself. Therefore, to update JGR, Deducer and Deducer Extra, go to the R console (not the GUI) and enter:

update.packages(c(“JGR”,”Deducer”,”DeducerExtras”))

1.
R core team. A language and environment for statistical computing. R foundation for statistical computing. [Internet]. Vienna, Austria; 2010. Available from: http://www.R-project.org/
1.
Fellows I. Deducer: A data analysis GUI for R. Journal of Statistical Software. 2012;49(8):1–15.
1.
Helbig M, Urbanek S, Fellows I. JGR: JGR – Java GUI for R [Internet]. 2013. Available from: http://CRAN.R-project.org/package=JGR
1.
RStudio. RStudio: Integrated development environment for R (Computer Software) [Internet]. Boston; 2013. Available from: http://www.rstudio.org
1.
Therneau T. Survival: a package for survival analysis in R. R package version 2.37. 2014.