Michael
2012-May-22 17:24 UTC
[R] In R, how do I execute a script that sets environment variables within the same shell session?
In R, how do I execute a script that sets environment variables within the same shell session? Hi all, Could you please shed some lights on how to do this? In a shell, I launched the R session. But then in R, I realized that some environment variables need to be set up. Of course I can use "Sys.setenv()"... But I have so many of them... And for some special reason, I have to first launch R and then run the script from within R to set up the environment variables... i.e. I cannot do the other way around, which is first execute the script in the shell, and then launch the R session(which is the usual sequenc of ordering)... So my question is: I have to launch R session first, and then run the scrip from within R. But if I naively use "shell" or "system", that's going to not affect the same shell that the R is using... I would like the R session to be able to access those "global" environment variables... How do I do that? Thank you! [[alternative HTML version deleted]]
Duncan Murdoch
2012-May-23 00:06 UTC
[R] In R, how do I execute a script that sets environment variables within the same shell session?
On 12-05-22 1:24 PM, Michael wrote:> In R, how do I execute a script that sets environment variables within the > same shell session? > > Hi all, > > Could you please shed some lights on how to do this? > > In a shell, I launched the R session. > > But then in R, I realized that some environment variables need to be set up. > > Of course I can use "Sys.setenv()"... > > But I have so many of them... > > And for some special reason, I have to first launch R and then run the > script from within R to set up the environment variables... > > i.e. > > I cannot do the other way around, which is first execute the script in the > shell, > > and then launch the R session(which is the usual sequenc of ordering)... > > So my question is: > > I have to launch R session first, and then run the scrip from within R. > > But if I naively use "shell" or "system", that's going to not affect the > same shell that the R is using... > > I would like the R session to be able to access those "global" environment > variables... > > How do I do that?You already answered it. Use Sys.setenv(). It will only affect the current process. Duncan Murdoch
Maybe Matching Threads
- Calling a .bat to set environment variables and subsequent .exe execution from within R
- PAM session setup and environment variables
- How do I modify sytem shell environment from within R?
- [LLVMdev] PATH and LD_LIBRARY_PATH
- BSD Auth: set child environment variables requested by login script [PATCH]