set environment variables for system() in R?

前端 未结 3 1127
独厮守ぢ
独厮守ぢ 2020-12-31 20:34

I\'ve been using R in Ubuntu to make system calls using system() for things like spinning up Amazon EC2 instances, managing files on S3, etc. If I start R from

相关标签:
3条回答
  • 2020-12-31 20:48

    I think you are confusing the issue. I fear this may be about login shells versus non-login shells. See the bash manual page for the fine print ... which has driven me bonkers in the past.

    That said, if you can set environment variables system-wide, you have a few options:

    • /etc/environment is a very good place as it is shell-agnostic should you ever use a different shell
    • for login versus non-login shells, the one way to get complete control that I found suitable was to put my changes into something like ~/.local_bashrc
    • the add . ~/.local_bashrc from and and all of

      • ~./bashrc
      • ~/.bash_profile
      • ~/.profile`

      etc pp.

    You can precede the sourcing with a echo Hello from FILE where you replace FILE with the name of the file. That shows you the difference between shells starting from login (eg via gdm et al), via ssh connection, via new xterm etc terminals and so on.

    0 讨论(0)
  • 2020-12-31 20:48

    You can force the system to read your .bashrc file by using the source command

    source ~/.bashrc
    

    Lots of inelegant and ugly ways to apply this

    0 讨论(0)
  • 2020-12-31 21:08

    You can try to set them in R itself using Sys.setenv.

    0 讨论(0)
提交回复
热议问题