[R] RScript.exe and map directory issue

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Fri Jun 1 00:57:18 CEST 2012


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Duncan Murdoch
> Sent: Thursday, May 31, 2012 3:27 PM
> To: Bert Jacobs
> Cc: r-help at r-project.org
> Subject: Re: [R] RScript.exe and map directory issue
> 
> On 12-05-31 4:40 PM, Bert Jacobs 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?
> 
> Probably you'll need to put the file path in quotes.  I suspect either
> single or double quotes will work.
> 
> I don't know how to put quotes in a quoted string in Excel, but I
> imagine there's a way.
> 
> Duncan Murdoch
> 

Single quotes will not work.  Windows requires double-quotes around path names that contain spaces which are passed to the shell/command prompt.  In addition, each path/filename with a space must be double-quoted separately.  In this instance, you may be able to use single-quotes for the outer set of quotes, thereby eliminating the need to double the inner quotes (because the outer quotes are for Excel and will be stripped before they get to the shell).


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