Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


In R to use a library it must be loaded using the 'library' function. To be able to load a library it must have been previouly installed. Boxes with grey background contain code snippets. 

The first step to install packages in R is selecting the CRAN (Comprehensive R Archive Network) mirror. Mirror selection and package installation can be done via R’s menu (Packages/Set CRAN mirror… followed by Packages/install package(s)…) or programmatically the via the function 'install.packages' (selecting the CRAN mirror using the argument 'repos'). Typically it is best to choose the cloud mirror (which automatically redirects to an appropriate server worldwide) or a mirror close to you (e.g. in your institution, country,..). A list of Comprehensive R Archive Network (CRAN) mirror URLs can be found here. Bellow are two examples of how to select a CRAN mirrors. In the first example the cloud mirror is selected, and in the second one an Australian mirror is selected. Before running this code you must uncomment (i.e. remove the '#' symbol) the line with the desired mirror. Boxes with grey background contain code snippets, and boxes with white background containt code (text) outputs.