I do not understand the point. The first function in R. My reason is that any code in .Rprofile will be received and executed when R starts anyway.
this is
.First<-function(){ library('devtools') }
and this one
library('devtools')
in.Rprofile have exactly the same effect.
However, here is an example that shows. The first may matter:
example 1, you can see that X11.options () $ type correctly becomes Xlib, as set in .Rprofile
>> cat .Rprofile .First <- function() { library(devtools) } setHook( packageEvent("grDevices", "onLoad"), function(...) grDevices::X11.options(type="Xlib") ) >> Rscript -e 'X11.options()$type' [1] "Xlib"
example 2, you can see that X11.options () $ type is still cairo, setHook in .Rprofile did not take effect
>> cat .Rprofile library(devtools) setHook( packageEvent("grDevices", "onLoad"), function(...) grDevices::X11.options(type="Xlib") ) >> Rscript -e 'X11.options()$type' [1] "cairo"
- In which case I absolutely must use. First function?
- why. First changed in the example above?
Thanks!
r
Jim green
source share