R: Difference between revisions

Jump to navigation Jump to search
56 bytes added ,  1 year ago
no edit summary
No edit summary
No edit summary
Line 65: Line 65:


<!--T:17-->
<!--T:17-->
<code>Rscript</code> 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.  
<code>Rscript</code> will automatically pass scripting-appropriate options <code>--slave</code> and <code>--no-restore</code> to the R interpreter. These also imply the <code>--no-save</code> option, preventing the creation of useless workspace files on exit.  


<!--T:67-->
<!--T:67-->
Line 94: Line 94:
=== install.packages() === <!--T:69-->
=== install.packages() === <!--T:69-->


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.
To install packages from [https://cran.r-project.org/ CRAN], you can use <code>install.packages</code> 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 <code>gcc</code> [[Utiliser des modules/en|module]] before trying to install any R packages. Use the same version of the <code>gcc</code> for all packages you install.
{{Command
{{Command
|module load gcc/9.3.0 r/4.0.2
|module load gcc/9.3.0 r/4.0.2
}}
}}
==== Installing for a specific R version ==== <!--T:18-->
==== Installing for a specific R version ==== <!--T:18-->
For example, to install the <tt>sp</tt> package that provides classes and methods for spatial data, use the following command on a login node:
For example, to install the <code>sp</code> package that provides classes and methods for spatial data, use the following command on a login node:


<!--T:19-->
<!--T:19-->
Line 110: Line 110:


<!--T:20-->
<!--T:20-->
If the argument <tt>repos</tt> is not specified, you will be asked to select an appropriate mirror for download. Ideally, it will be geographically close to the cluster you're working on.
If the argument <code>repos</code> is not specified, you will be asked to select an appropriate mirror for download. Ideally, it will be geographically close to the cluster you're working on.


<!--T:21-->
<!--T:21-->
Some packages require defining the environment variable <tt>TMPDIR</tt> before installing.
Some packages require defining the environment variable <code>TMPDIR</code> before installing.


==== Installing for one or many R versions ==== <!--T:79-->
==== Installing for one or many R versions ==== <!--T:79-->
Line 125: Line 125:


<!--T:80-->
<!--T:80-->
In your submission script, you then have to load the desired R module and set the local library directory with <tt>export R_LIBS=~/.local/R/$EBVERSIONR/</tt>.
In your submission script, you then have to load the desired R module and set the local library directory with <code>export R_LIBS=~/.local/R/$EBVERSIONR/</code>.


=== Dependencies === <!--T:5-->
=== Dependencies === <!--T:5-->
Line 142: Line 142:


=== Downloaded packages === <!--T:22-->
=== Downloaded packages === <!--T:22-->
To install a package that you downloaded (i.e. not using <code>install.packages()</code>), you can install it as follows. Assuming the package is named <tt>archive_package.tgz</tt>, run the following command in a shell:
To install a package that you downloaded (i.e. not using <code>install.packages()</code>), you can install it as follows. Assuming the package is named <code>archive_package.tgz</code>, run the following command in a shell:
{{Command
{{Command
|R CMD INSTALL -l 'path for your local (home) R library' archive_package.tgz
|R CMD INSTALL -l 'path for your local (home) R library' archive_package.tgz
Line 150: Line 150:


<!--T:77-->
<!--T:77-->
Using the R command <tt>system()</tt> you can execute commands in the ambient environment from inside R. On our clusters, this can lead to problems because R will give an incorrect value to the environment variable <tt>LD_LIBRARY_PATH</tt>. You can avoid this problem by using the syntax <tt>system("LD_LIBRARY_PATH=$RSNT_LD_LIBRARY_PATH <my system call>")</tt> in your R system calls.
Using the R command <code>system()</code> you can execute commands in the ambient environment from inside R. On our clusters, this can lead to problems because R will give an incorrect value to the environment variable <code>LD_LIBRARY_PATH</code>. You can avoid this problem by using the syntax <code>system("LD_LIBRARY_PATH=$RSNT_LD_LIBRARY_PATH <my system call>")</code> in your R system calls.




rsnt_translations
57,772

edits

Navigation menu