HenrikBengtsson / startup

:wrench: R package: startup - Friendly R Startup Configuration
https://henrikbengtsson.github.io/startup/
163 stars 5 forks source link

R_STARTUP_INIT: Code string evaluated during the R startup process #67

Closed HenrikBengtsson closed 5 years ago

HenrikBengtsson commented 5 years ago

Background

It is not possible to evaluate an R expression from the CLI prior to the first R prompt. For example, the following will evaluate the R expression, but then terminate R:

$ R --quiet -e 'message("hello")' 
> message("hello")
hello
> 
> 

Idea

With startup::startup() in ~/.Rprofile, we could support something like:

$ R_STARTUP_INIT='message("hello")' R --quiet
hello

> 1 + 2
[1] 3

>

To be decided: Should this be evaluated at the beginning or the end of the startup process? By doing it at the end, the expression can rely on user's custom setup to be in place.

HenrikBengtsson commented 5 years ago

Added

$ R_STARTUP_INIT='message("Current time: ", Sys.time())' R --quiet
Current time: 2019-03-28 13:58:53
>