[R] system() not accepting strings from cat()

ig2ar-saf1 at yahoo.co.uk ig2ar-saf1 at yahoo.co.uk
Tue Mar 10 21:01:48 CET 2009


Hi again R-ists,

How do you construct a string that you can pass to system()?

For instance. Say I do

> system("echo Hello!")
Hello!

That works. Now the alternative: I need to construct the string like this

> a <- "echo"
> b <- "Hello!"
> c <- "\n"
> cat(a, b, c)
echo Hello!

Looks nice... but see what happens when I try to use it

> system(cat(a, b, c))
echo Hello! 
Error in system(command, intern) : non-empty character argument expected

I have googled extensively in and out of r-lists but I can't find a solution.

Can anybody help?







More information about the R-help mailing list