HenrikBengtsson / startup

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

startup(): Add argument and env var to (always) skip .RData #42

Closed HenrikBengtsson closed 4 years ago

HenrikBengtsson commented 6 years ago

A .RData file be loaded when R/Rscript is started, unless --no-restore-data (or --vanilla) is given. Using startup::startup(), it would be possible to have this as an argument, which could default to an env variable R_STARTUP_RDATA, to control how to handle such .RData files. One could:

  1. R_STARTUP_RDATA=default: Handle it as default (as now)
  2. R_STARTUP_RDATA=rename: Automatically rename it so it's not loaded (emulate a permanent --no-restore-data), e.g. .RData -> .RData.20171212.
  3. R_STARTUP_RDATA=remove: Automatically remove it, because you think they're always bad and only there because of a mistakes.
  4. R_STARTUP_RDATA=prompt: Prompt the user whether they wish to load .RData or not? (Is it ok to prompt user at startup?)

Not sure if this is a good idea or needed, but it's possible because:

0.000s: System information:
0.001s: - R call: /usr/lib/R/bin/exec/R
0.001s: - Current directory: ‘/home/hb’
0.001s: - User's home directory (‘~’): ‘/home/hb’
0.002s: The following has already been processed by R:
0.002s: - ‘/usr/lib/R/etc/Renviron’ (21 lines; 1852 bytes)
0.003s: - ‘/usr/lib/R/etc/Renviron.site’ (0 lines; 934 bytes)
0.003s: - ‘/usr/lib/R/etc/Rprofile.site’ (0 code lines; 819 bytes)
0.004s: - ‘.Rprofile’ (2 code lines; 375 bytes)
0.004s: startup::startup()-specific processing ...
[...]
0.337s: - unloading the 'startup' package
0.338s: startup::startup()-specific processing ... done
0.338s: The following will be processed next by R:
0.338s: - './.RData' (binary file; 24600 bytes)
0.339s: - './.Rhistory' (501 lines; 14060 bytes)
[Previously saved workspace restored]
HenrikBengtsson commented 6 years ago

Maybe add an option to prompt the user whether they wish to load .RData or not? (Is it ok to prompt user at startup?)

Examples: