I am an "admin" for a shared server for statisticians on a research study.
I have a list of about 100 packages used by our senior statistician on the study. I would prefer to load and update them periodically from an R shell (versus inside RStudio Server).
I think using the default system location (/opt/R/4.2.0/lib/R/library
) is the way to go. While the RStudio Server setup allows users to load their own, having a default group loaded per our statistician's ask seems wise.
The commands I was given which load these packages have the syntax below (only including a few lines of the script). They seem to install if the package doesn't already exist.
If I set an environment variable properly, then run R as root and issue all these commands, would the libraries be placed appropriately in the library folder that I set in the environment variable (in this example, it'd be /opt/R/4.2.0/lib/R/library
)?
Since this is Linux, we would want to install from sources when appropriate, which I think is default loading for this OS.
Is there a better/easier way to do this?
if (!requireNamespace("markdown", quietly = TRUE)) install.packages("markdown")
if (!requireNamespace("devtools", quietly = TRUE)) install.packages("devtools")
# graphical/table output
if (!requireNamespace("igraph", quietly = TRUE)) install.packages("igraph")
if (!requireNamespace("ggplot2", quietly = TRUE)) install.packages("ggplot2")
# advanced regression
if (!requireNamespace("glmnet", quietly = TRUE)) install.packages("glmnet")
if (!requireNamespace("sm", quietly = TRUE)) install.packages("sm")
RStudio Server packageStatus()
:
Environment:
CentOS 8
RStudio Server 1.4.1717-3
R 4.2 (4.1.3, 3.6.3)