R: Difference between revisions

Jump to navigation Jump to search
172 bytes added ,  5 years ago
no edit summary
No edit summary
No edit summary
Line 61: Line 61:
This front-end will automatically pass scripting-appropriate options <tt>--slave</tt> and <tt>--no-restore</tt> to the R interpreter. These also imply the <tt>--no-save</tt> option, preventing the creation of useless workspace files on exit. Note that any calculations last more than two or three minutes should not be run on the login node of the cluster but inside of a [[Running jobs|job]].
This front-end will automatically pass scripting-appropriate options <tt>--slave</tt> and <tt>--no-restore</tt> to the R interpreter. These also imply the <tt>--no-save</tt> option, preventing the creation of useless workspace files on exit. Note that any calculations last more than two or three minutes should not be run on the login node of the cluster but inside of a [[Running jobs|job]].


== Installing R packages == <!--T:18-->
== Installing R packages ==  
To install packages from [https://cran.r-project.org/ CRAN], you can use the <tt>install.packages</tt> facility inside the R interpreter while running in an interactive session on the cluster's login node. Many R packages are developed using the Gnu family of compilers so we recommend that you load a <tt>gcc</tt> module before trying to install any R packages, using the same version of the <tt>gcc</tt> module for each package:
 
=== install.packages() ===
 
<!--T:18-->
To install packages from [https://cran.r-project.org/ CRAN], you can use <tt>install.packages</tt> while running an interactive R session on the cluster's login node. Many R packages are developed using the Gnu family of compilers so we recommend that you load a <tt>gcc</tt> [[Utiliser des modules/en|module]] before trying to install any R packages. Use the same version of the <tt>gcc</tt> for all packages you install.
{{Command
{{Command
|module load gcc/5.4.0
|module load gcc/5.4.0
Line 82: Line 86:
Some packages require defining the environment variable <tt>TMPDIR</tt> before installing.
Some packages require defining the environment variable <tt>TMPDIR</tt> before installing.


<!--T:22-->
=== Dependencies ===<!--T:5-->
To install a package that you downloaded (i.e. not from CRAN), you can install it as follow. Assuming the package is named <tt>archive_package.tgz</tt>, run the following command in a shell:
Some packages depend on external libraries which are already installed on our clusters. If the library you need is listed at [[Available software]], then load the appropriate [[Utiliser des modules/en|module]] before installing the package that requires it.
{{Command
|R CMD INSTALL -l 'path for your local (home) R library' archive_package.tgz
}}


<!--T:5-->
For example, the package <code>rgdal</code> requires a library called <code>gdal</code>. Running <code>module spider gdal/2.2.1</code> shows that it requires <code>nixpkgs</code> and <code>gcc</code> modules. If you took the advice above to load <code>gcc</code> then both these should already be loaded. Verify this by running
You might also have to load various other modules depending on the packages you need to install. For example, "rgdal" will require that you load a module called <tt>gdal</tt>, which itself requires that you load the <tt>nixpkgs</tt> and <tt>gcc</tt> modules. The <tt>nixpkgs</tt> module should already be loaded by default. You can ensure that it is by running


<!--T:6-->
<!--T:6-->
Line 96: Line 96:
}}  
}}  


<!--T:7-->
<!--T:9-->
If <tt>nixpkgs</tt> is not listed, you can load it by running
If any package fails to install, be sure to read the error message carefully as it might give you details concerning additional modules you need to load.  See [[Utiliser des modules/en|Using modules]] for more on the <code>module</code> family of commands.


<!--T:8-->
=== Downloaded packages ===<!--T:22-->
To install a package that you downloaded (i.e. not using <code>install.packages()</code>), you can install it as follow. Assuming the package is named <tt>archive_package.tgz</tt>, run the following command in a shell:
{{Command
{{Command
|module load nixpkgs/16.09
|R CMD INSTALL -l 'path for your local (home) R library' archive_package.tgz
}}
 
<!--T:9-->
If any package fails to install, be sure to read the error message carefully, as it might give you some details concerning some additional modules you need to load. You can also find out if a module is dependent on any other module by running
{{Command
|module spider gdal/2.2.1
}}
}}


Bureaucrats, cc_docs_admin, cc_staff
2,879

edits

Navigation menu