[R] RScript.exe and map directory issue
Nordlund, Dan (DSHS/RDA)
NordlDJ at dshs.wa.gov
Fri Jun 1 00:05:50 CEST 2012
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of R. Michael Weylandt
> Sent: Thursday, May 31, 2012 2:51 PM
> To: Bert Jacobs
> Cc: r-help at r-project.org
> Subject: Re: [R] RScript.exe and map directory issue
>
> Not on Windows so I can't test, but I imagine you need to escape the
> space: try this:
>
> Call Shell(rPath & "\Rscript.exe C:\Work\Latest\ 1\_Test.R", vbHide)
>
> Michael
>
> On Thu, May 31, 2012 at 4:40 PM, Bert Jacobs
> <bert.jacobs at figurestofacts.be> wrote:
> > Hi,
> > I'm trying to run on Windows 7 a scriptfile with Rscript.exe from
> within
> > Excel 2010 with the following code:
> > Call Shell(rPath & "\Rscript.exe C:\Work\Latest\_Test.R", vbHide)
> >
> > The good news is: the above code works perfectly, but ...
> >
> > If I add white spaces to my map directory, like:
> > Call Shell(rPath & "\Rscript.exe C:\Work\Latest 1\_Test.R", vbHide)
> >
> > In the above case or the RScript.exe doesn't run the file anymore.
> > Could someone explain to me how this comes and how I can deal with
> it?
> >
> > Kind regards,
> > Bert
The backslash character does not escape anything in the shell in Windows. You need to make sure that filenames/paths with spaces are surrounded by double quotes. So try something like
Call Shell(rPath & "\Rscript.exe ""C:\Work\Latest 1\_Test.R""", vbHide)
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
More information about the R-help
mailing list