First, it looks like there is bug in the documentation...
According to the documentation for system():
http://stat.ethz.ch/R-manual/R-patched/library/base/html/system.html
input if a character vector is supplied, this is copied one string per
line to a temporary file, and the standard input of command is
redirected to the file
This seems to mean that the standard input of command is redirected *from*
the file. From the file, to the command. Example:
> i <- 42
> system( "cat -", input=as.character(i) )
42
I guess the documentation needs to be clarified because I couldn't
understand what it meant.
Second, I'm trying to use a system call to write files with names based on
an integer value in an R variable (in this case the variable is called
"i"). As above, I can do this (on a GNU/Linux system):
> system( "cat -", input=sprintf("%04d", i) )
0005
I am running bash, but system calls go to sh. I want to be able to put
that input string ("0005") into a variable and do something like this:
system( "i=`cat /dev/stdin` ; run_script > file${i}.out" ,
input=sprintf("%04d", i) )
I think my problem is more with sh than with R, but someone here must have
tried this, so I'm hoping I can get an answer here. Thanks in advance.
Best,
Mike
--
Michael B. Miller, Ph.D.
Minnesota Center for Twin and Family Research
Department of Psychology
University of Minnesota