HenrikBengtsson / startup

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

startup(ask = c("no", "yes", "each")) for selective loading of startup files #20

Open HenrikBengtsson opened 7 years ago

HenrikBengtsson commented 7 years ago

Occasionally, some part of your startup settings conflicts with a function call or package. You know this because things work when you use R --vanilla. Trying to find exactly where the conflict is. In such cases it would be useful to be able to quickly disable one or more startup files.

A poor mans version for this would be to have startup() as before processing each file, e.g.

> startup::startup(ask = "each")
[...]
0.011s: Found startup directory ‘~/.Rprofile.d’.
0.022s: Processing 3 Rprofile files ...
0.029s:  - /home/hb/.Rprofile.d/000.public/libpaths.R.  Process? [Y/n]: 
2.081s:  - /home/hb/.Rprofile.d/000.public/repos.R.  Process? [Y/n]: n
3.353s: Processing 19 Rprofile files ... done

It should be possible to control this from the command line, e.g.

$ R_STARTUP_ASK=each R
[...]

A fancier version would be to record the answers and save as a config file that can be reused and tweaked, e.g.

$ R_STARTUP_CONFIG=config.yml R

where config.yml may contain:

exclude:
  - .Rprofile.d/000.public/repos.R

exclude_pattern:
  - .*test.*

One could also support a .startup.yml, which if found in a startup directory that is about to be processes, will be processed / acknowledged and be applied recursively.