my testing .Rprofile
:
message("~/.Rprofile starting")
options(repos="https://cran.microsoft.com/")
if (!require("data.table")) install.packages("data.table")
message("~/.Rprofile ending")
works if I start with R --vanilla
and then source("~/.Rprofile")
, but not with a standard startup R
, in which case the automatic sourcing of ~/.Rprofile
gives me
~/.Rprofile starting
Loading required package: data.table
Error: could not find function "install.packages"
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘data.table’
>
is there something (a library) that needs to be loaded first, that is usually loaded only after .Rprofile
is executed (otherwise)?
I tried to debug this through .libPaths()
, but lost it after I could not figure out where .lib.loc
comes from in the function. there must be some specific startup functioning related to the embedding of the .Rprofile somewhere, which defines .lib.loc and does some more stuff.