[R] Rprofile.site and automatic installation of missing packages
petr@p|k@| @end|ng |rom prechez@@cz
Tue Mar 21 13:04:42 CET 2023
I am trying to install missing (not installed) packages during startup of R
through code in Rprofile.site but I miserably failed and I am not sure what
I am doing wrong.
R is installed to C:Program files but it is not writable for the users,
therefore I cannot change Rprofile.site located in root etc directory. I
however can put Rprofile.site in users home directory (Documents) and use it
for R startup setting (partly).
However I want for less experienced users to put a code here to check
installed packages, check if some specified set of packages is installed and
install them, but it is not working.
The code in Rprofile.site is:
test <- scan("pack.txt", character(), quote = "")
inst <- installed.packages()
install.packages(test[!test %in% inst], repos="https://cloud.r-project.org")
An example of pack.txt is e.g.
but the code is not executed and packages are not installed. If I use this
code after R starts, everything is OK and packages are installed to
The same applies if I put e.g. library(MASS) in the Rprofile.site, the
package is not loaded but after R is live, library(MASS) loads a package.
So my question is What is the best way to check after fresh R installation
if some predefined set of packages is installed and if not, perform an
installation without user intervention in Windows environment?
S pozdravem | Best Regards
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the R-help