{"id":1122,"date":"2019-06-26T12:42:02","date_gmt":"2019-06-26T19:42:02","guid":{"rendered":"https:\/\/in.nau.edu\/hpc\/?page_id=1122"},"modified":"2024-08-13T15:16:31","modified_gmt":"2024-08-13T22:16:31","slug":"r-packages","status":"publish","type":"page","link":"https:\/\/in.nau.edu\/arc\/r-packages\/","title":{"rendered":"R Packages"},"content":{"rendered":"<h1>R Packages<\/h1>\n<p>On Monsoon, you can install R packages to expand the functionality of your R projects.<\/p>\n<h2>Installing R Packages<\/h2>\n<p>To install a package in R, open an R shell and use the install.packages function:<\/p>\n<pre><code>[abc123@wind ~] module load R\r\n[abc123@wind ~] R\r\n&gt; install.packages(c(\"package1\",\"package2\",...,\"packageN\"))<\/code><\/pre>\n<p>In this form, R will prompt you for the repository mirror you want to use and will install each package in turn, including any dependencies. You will also be prompted for the location to store your installed package, which defaults to <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">\/home\/&lt;username&gt;\/R\/&lt;R version&gt;\/packagename<\/span>.<\/p>\n<h2>Specifying CRAN Mirror<\/h2>\n<p>To prevent R from prompting for the CRAN mirror to use, you can specify one within the <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">install.packages<\/span> function:<\/p>\n<pre><code>&gt; install.packages(c(\"package1\"), repos = \"http:\/\/cran.case.edu\")<\/code><\/pre>\n<p>The same format works for other repositories such as Bioconductor, R-forge, etc.<\/p>\n<h2>Installing From GitHub<\/h2>\n<p>To install packages from GitHub sites, we highly recommend referring to the GitHub project documentation. However, a general GitHub package installation can be done using the <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">require<\/span> and <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">install_github<\/span> functions:<\/p>\n<pre><code>require(devtools)\r\ninstall_github(\"package1\")<\/code><\/pre>\n<h2>Advanced Configurations<\/h2>\n<p>For more complex installations that require other specific libraries, you can specify configure.vars to specify include and library paths. For example, to install the <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">rzmq<\/span> package, you&#8217;d need the <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">zeromq<\/span> module loaded before starting R and you&#8217;d need to specify the include and library paths:<\/p>\n<pre><code>[abc123@wind ~]$ module load zeromq R\/3.6.0\r\n[abc123@wind ~]$ R\r\n&gt; install.packages(c('rzmq'),repos = \"http:\/\/cran.case.edu\", configure.vars=\"INCLUDE_DIR=\/packages\/zeromq\/3.2.5\/include LIB_DIR=\/packages\/zeromq\/3.2.5\/lib\")<\/code><\/pre>\n<p>Finally, you can use package config for packages that want it, as well. This example installs the <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">rjags<\/span> package:<\/p>\n<pre><code>[abc123@wind ~]$ module load jags\r\n[abc123@wind ~]$ export PKG_CONFIG_PATH=\/packages\/jags\/4.3.0\/lib\/pkgconfig\r\n[abc123@wind ~]$ pkg-config \u2013\u2013modversion jags\r\n[abc123@wind ~]$ R\r\n&gt; install.packages(c('rjags'),repos = \"http:\/\/cran.case.edu\", configure.args=\"\u2013\u2013enable-rpath\")<\/code><\/pre>\n<p>As always, please don&#8217;t hesitate to <a href=\"https:\/\/in.nau.edu\/arc\/contact-us\/\">contact us<\/a> if you need further assistance with R package installation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>R Packages On Monsoon, you can install R packages to expand the functionality of your R projects. Installing R Packages To install a package in R, open an R shell and use the install.packages function: [abc123@wind ~] module load R [abc123@wind ~] R &gt; install.packages(c(&#8220;package1&#8243;,&#8221;package2&#8243;,&#8230;,&#8221;packageN&#8221;)) In this form, R will prompt you for the repository [&hellip;]<\/p>\n","protected":false},"author":469,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","ring_central_script_selection":"","footnotes":""},"class_list":["post-1122","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/1122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/users\/469"}],"replies":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/comments?post=1122"}],"version-history":[{"count":8,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/1122\/revisions"}],"predecessor-version":[{"id":3585,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/1122\/revisions\/3585"}],"wp:attachment":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/media?parent=1122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}