Re: [R] RScript.exe and map directory issue
To put double quotes in a string in VBA one has to use double double quotes str = "a string with a ""quoted"" word" On Jun 1, 2012, at 12:26 AM, Duncan Murdoch wrote: > 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 > > __ > 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. __ 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.
Re: [R] RScript.exe and map directory issue
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Duncan Murdoch > Sent: Thursday, May 31, 2012 3:27 PM > To: Bert Jacobs > Cc: r-help@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 __ 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.
Re: [R] RScript.exe and map directory issue
Em 31/5/2012 17:40, Bert Jacobs escreveu: 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? Bert, I'm not a Windows guru, and do not have Windows 7 available to ascertain it, but in earlier versions of Windows, the subterfuge used to be to employ the "8.3" short name of the file (in fact the whole path) to circumvent the issue of spaces in {file,directory}names. To get the shortened name that Windows ascribe to a long, and potentially with spaces, in a filename you issue the command dir /x and you'd see a translation of longname to 8.3 filename. HTH -- Cesar Rabak __ 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.
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 __ 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.
Re: [R] RScript.exe and map directory issue
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of R. Michael Weylandt > Sent: Thursday, May 31, 2012 2:51 PM > To: Bert Jacobs > Cc: r-help@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 > 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 __ 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.
Re: [R] RScript.exe and map directory issue
Thx Michael, After some testing (with more luck then craftmanship) it appears that following code works: Call Shell(rPath & "\Rscript.exe " & """C:\Work\Latest 1\_Test.R""", vbHide) I'll also try your solution. SY, Bert -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: 31 May 2012 23:51 To: Bert Jacobs Cc: r-help@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 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 > > __ > 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. __ 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.
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 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 > > __ > 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. __ 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.
[R] RScript.exe and map directory issue
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 __ 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.