On Jun 4, 2015, at 8:47 AM, Wall, Wade A ERDC-RDE-CERL-IL 
<wade.a.w...@usace.army.mil> wrote:
> 
> Hi all,
> 
> I am trying to pass arguments to a python script using R, but am running into 
> a problem with the string being split on the white spaces. Investigation on 
> the python end suggests that it is happening upstream from python, because 
> other shells such as bash have generated similar errors.
> 
> Here is example code.
> 
> R script:
> 
> test = "./Example.py"
> string1 = "ThisWorks"
> string2 = "This doesn't"
> 
> system2('python',args = c(as.character(test),as.character(string1))) ## This 
> works
> system2('python',args = c(as.character(test),as.character(string2))) ## This 
> doesn't
> 
> Python script:
> 
> from sys import argv
> script, string = argv
> print script
> print string
> 
> What happens is that string 2 is splits into "This" and "doesn't". Does 
> anyone know how to resolve this issue? Of course I can remove the white 
> spaces, but that may be somewhat inconvenient.
> 
> Thanks for any help.
> 
> 
> Wade


See ?shQuote

> shQuote(string2)
[1] “\"This doesn’t\""


Regards,

Marc Schwartz

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to