{"id":918,"date":"2018-11-19T17:25:22","date_gmt":"2018-11-19T17:25:22","guid":{"rendered":"https:\/\/portal.supercomputing.wales\/?page_id=918"},"modified":"2018-11-19T17:25:22","modified_gmt":"2018-11-19T17:25:22","slug":"installing-r-packages","status":"publish","type":"page","link":"https:\/\/portal.supercomputing.wales\/index.php\/installing-r-packages\/","title":{"rendered":"Installing R Packages"},"content":{"rendered":"<p>To install an R package you will need to first manually download it from its website. Most popular packages are part of the <a href=\"https:\/\/cran.r-project.org\/web\/packages\/index.html\">CRAN<\/a> archive. You will need to find a link to the source code of the package you require and download this with the wget or curl command. For example the LearnBayes package (<a href=\"https:\/\/cran.r-project.org\/web\/packages\/LearnBayes\/index.html\">https:\/\/cran.r-project.org\/web\/packages\/LearnBayes\/index.html<\/a>) can be downloaded from <a href=\"https:\/\/cran.r-project.org\/src\/contrib\/LearnBayes_2.15.1.tar.gz\">https:\/\/cran.r-project.org\/src\/contrib\/LearnBayes_2.15.1.tar.gz<\/a>.<br \/>\n<pre class=\"preserve-code-formatting\">wget https:\/\/cran.r-project.org\/src\/contrib\/LearnBayes_2.15.1.tar.gz<\/pre><br \/>\nThe package can now be installed by loading the R module and running R CMD INSTALL, then specifying the -l flag for a local install, the directory we wish to install in and finally the name of the package file we just downloaded.<br \/>\n<pre class=\"preserve-code-formatting\">module load R\nR CMD INSTALL -l ~\/R\/libs LearnBayes_2.15.1.tar.gz<\/pre><br \/>\nFinally we need to tell R where to find the libraries we&#8217;ve installed. This is done by setting the R_LIBS environment variable with the export command. You might want to add this command to any Slurm scripts which you write for using with R.<br \/>\n<pre class=\"preserve-code-formatting\">export R_LIBS=~\/R\/libs<\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To install an R package you will need to first manually download it from its website. Most popular packages are part of the CRAN archive. You will need to find a link to the source code of the package you require and download this with the wget or curl command. For example the LearnBayes package [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"class_list":["post-918","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/portal.supercomputing.wales\/index.php\/wp-json\/wp\/v2\/pages\/918","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/portal.supercomputing.wales\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/portal.supercomputing.wales\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/portal.supercomputing.wales\/index.php\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/portal.supercomputing.wales\/index.php\/wp-json\/wp\/v2\/comments?post=918"}],"version-history":[{"count":1,"href":"https:\/\/portal.supercomputing.wales\/index.php\/wp-json\/wp\/v2\/pages\/918\/revisions"}],"predecessor-version":[{"id":919,"href":"https:\/\/portal.supercomputing.wales\/index.php\/wp-json\/wp\/v2\/pages\/918\/revisions\/919"}],"wp:attachment":[{"href":"https:\/\/portal.supercomputing.wales\/index.php\/wp-json\/wp\/v2\/media?parent=918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}