I use a Mac (10.4.11 Mac Os X). In my .tcshrc I define an environmental variable MY. Is it possible to find out its value from inside R? When one loads R for Mac OS X Cocoa GUI written by: Simon Urbanek Stefano M. Iacus are files like .tcshrc read by R? Can I make the value of this environmental variable available to R? Sys.getenv() produces a lot of output, with the values of many environmental variables, but not this one. Do I need a file with the correct value of MY, and have both R and my Unix shell read the same file, or is there a better way to proceed? I want to avoid duplicating the information in source files, as this can lead to a setup that is very hard to maintain. Thanks for any help. David -- View this message in context: http://www.nabble.com/Environmental-variables-tp21782296p21782296.html Sent from the R help mailing list archive at Nabble.com.
can you use the system function? system("echo $PATH") On Feb 2, 11:10?am, David Epstein <David.Epst... at warwick.ac.uk> wrote:> I use a Mac (10.4.11 Mac Os X). > > In my .tcshrc I define an environmental variable MY. > Is it possible to find out its value from inside R? When one loads > R for Mac OS X Cocoa GUI written by: > ? ? ? ? Simon Urbanek > ? ? ? ? Stefano M. Iacus > are files like .tcshrc read by R? > > Can I make the value of this environmental variable available to R? > > Sys.getenv() produces a lot of output, with the values of many environmental > variables, but not this one. > > Do I need a file with the correct value of MY, and have both R and my Unix > shell read the same file, or is there a better way to proceed? I want to > avoid duplicating the information in source files, as this can lead to a > setup that is very hard to maintain. > > Thanks for any help. > David > -- > View this message in context:http://www.nabble.com/Environmental-variables-tp21782296p21782296.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
On Sun, 1 Feb 2009, David Epstein wrote:> > I use a Mac (10.4.11 Mac Os X). > > In my .tcshrc I define an environmental variable MY. > Is it possible to find out its value from inside R? When one loads > R for Mac OS X Cocoa GUI written by: > Simon Urbanek > Stefano M. Iacus > are files like .tcshrc read by R? > > Can I make the value of this environmental variable available to R? >Did you try starting the R GUI from the command line whilst using tcsh? <username>% /Applications/R.app/Contents/MacOS/R & The R GUI when started by launch'ing it picks up different environment vars than when starting it from a shell. And Sys.getenv() would show them. HTH, Chuck p.s. R-sig-mac is a better place for this question.> Sys.getenv() produces a lot of output, with the values of many environmental > variables, but not this one. > > Do I need a file with the correct value of MY, and have both R and my Unix > shell read the same file, or is there a better way to proceed? I want to > avoid duplicating the information in source files, as this can lead to a > setup that is very hard to maintain. > > Thanks for any help. > David > -- > View this message in context: http://www.nabble.com/Environmental-variables-tp21782296p21782296.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
David Epstein wrote:> I use a Mac (10.4.11 Mac Os X). > > In my .tcshrc I define an environmental variable MY. > Is it possible to find out its value from inside R? When one loads > R for Mac OS X Cocoa GUI written by: > Simon Urbanek > Stefano M. Iacus > are files like .tcshrc read by R? > > Can I make the value of this environmental variable available to R? > > Sys.getenv() produces a lot of output, with the values of many environmental > variables, but not this one. > > Do I need a file with the correct value of MY, and have both R and my Unix > shell read the same file, or is there a better way to proceed? I want to > avoid duplicating the information in source files, as this can lead to a > setup that is very hard to maintain.R launched from the dock will not inherit variables from .bashrc or .tcshrc because it's not a child process of the shell. You have to set the variables in an XML file called environment.plist, inside a directory .MacOSX in your home directory (create it if it doesn't exist), e.g.: macbook:~ gad$ cat .MacOSX/environment.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PATH</key> <string>/usr/bin:/bin:/usr/sbin:/sbin:/sw/bin:/usr/local/bin:/sw/sbin:/usr/X11/bin:/usr/local/git/bin</string> <key>JAVA_HOME</key> <string>/Library/Java/Home</string> </dict> </plist> -- Gad Abraham Dept. CSSE and NICTA The University of Melbourne Parkville 3010, Victoria, Australia email: gabraham at csse.unimelb.edu.au web: http://www.csse.unimelb.edu.au/~gabraham