I have an R file R_test.R saved in C:\R_test folder. The R_test.R looks like this:
setwd("C:/R_test") rnorm(100) write(rnorm(100),"data.txt") q(save="no", runLast = F) Next I would like use an Excel VBA/macro Shell() function to call R and execute R_test.R file. The syntax is *Shell(pathname*[*,windowstyle*]*)* I wrote an Excel macro RunRcode like this: Sub RunRcode() Dim RetVal RetVal = "C:\Program Files\R\R-2.10.1\bin\Rgui.exe & C:\R_test\R_test.R RetVal = Shell(RetVal, vbNormalFocus) End Sub When this macro is run, the R is opened but R_test.R file is ignored. If I change RetVal = "C:\Program Files\R\R-2.10.1\bin\Rgui.exe & C:\R_test\R_test.R To RetVal = "C:\Program Files\R\R-2.10.1\bin\Rgui.exe&C:\R_test\R_test.R (that is, no space before and after the & sign as some suggested), I got error msg run-time error 53 file not found). Is there anyone can give me a hand on how to make RunRcode macro work? Thanks kz [[alternative HTML version deleted]]
______________________________________________ R-help@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.