[R] Setting Windows environment variables via a batch file

Dennis Fisher fisher at plessthan.com
Tue Aug 23 20:40:09 CEST 2011


R 2.13
Vista

Colleagues,

I have encountered a problem with Windows environment variables that I don't understand.  My R code is designed to execute another program that uses Intel Fortran.  Intel Fortran apparently has some complicated issues regarding environment variables.  As a result, Intel provides a batch file (FortranVars.bat) that sets all the environment variables.  If I am working at a Command Prompt (i.e., at the command line, not in R), the following happens:
	1.  When I open the Command Prompt, I type "set %path%" and I get some output
	2.  I then execute the batch file -  the batch batch file returns a message "Intel (R) Visual Fortran ..." indicating that it was executed (and there is no error or warning from the OS).
	3.  If I type "set %path%" again, the output reflects the environment variables added by the batch file.
So far, so good.

Now I try the same from within R.
	1.  I type shell("set") and I examine the output for path (for unclear reasons, executing shell("set %path%") resulted in a warning:
		"running command ... had status 1"
	2.  i then execute the batch file -- same message as before
	3.  I type shell("set")" -- the output is unchanged.
	4.  I also tried executing step 2 preceded by "@ call".  no success.

I am not sure where the problem lies (incidentally, the behavior may be different in Windows 7 so I would appreciate answers relevant to Vista).  Does anybody have any insights?  

Thanks in advance.

Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com



More information about the R-help mailing list