Luca Cerone
2014-Apr-01 08:41 UTC
[R] Environment variable defined in .bashrc is not recognized by R
Dear all, in my .bashrc file I have set the environment variable R_HISTFILE like this: export R_HISTFILE="$HOME/.Rhistory" I then use it in my .Rprofile to have R writing all the history in a single file, rather than on a per directory basis. However this doesn't work becaus R_HISTFILE is not recognized by R. If I type: Sys.getenv("R_HISTFILE") the output is: "" How can I get R recognizing environment variables? Best, Luca -- Luca Cerone Skype: luca.cerone
Rainer M Krug
2014-Apr-01 09:25 UTC
[R] Environment variable defined in .bashrc is not recognized by R
Luca Cerone <luca.cerone at gmail.com> writes:> Dear all, > in my .bashrc file I have set the environment variable R_HISTFILE like this: > > export R_HISTFILE="$HOME/.Rhistory" > > I then use it in my .Rprofile to have R writing all the history in a > single file, rather than on a per directory basis. > However this doesn't work becaus R_HISTFILE is not recognized by R.Which OS? How do you start R? There is a difference between login shell (executed when you log in) and non-log in (I thik interactive shell? don't know the actual name). .baschrc is only executed after you are logged in and start the shell. So when you start R from the shell, it should work - you can check by echo $R_HISTFILE which should show you the value of the variable. If you are starting R the R gui (on Mac or RStudio) .bashrc is not sourced. Checo online for the file which will be sourced by the login shell - different between OS and distros. Cheers, Rainer> > If I type: Sys.getenv("R_HISTFILE") > the output is: "" > > How can I get R recognizing environment variables? > > Best, > Luca-- Rainer M. Krug email: Rainer<at>krugs<dot>de PGP: 0x0F52F982 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 494 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20140401/374b9258/attachment-0002.bin>