Hey, I'm generating a .jpeg file for a web application passing parameters to R via cgi. R gets the parameters by using commandArgs, which are passed to a variable named j and z j<-commandArgs()[3] z<-commandArgs()[4] Later I want to use the characters strings of the argument which the variables are holding for my filename, e.g.: jpeg(file="d:/data/images/jz.jpeg",...) i tried to use paste and as.character, but neither worked out the way i want it to. thanks for any advice, Lars Claussen
Lars wrote:> Hey, > > I'm generating a .jpeg file for a web application passing parameters to > R via cgi. R gets the parameters by using commandArgs, which are passed > to a variable named j and z > > j<-commandArgs()[3] > z<-commandArgs()[4] > > Later I want to use the characters strings of the argument which the > variables are holding for my filename, e.g.: > > jpeg(file="d:/data/images/jz.jpeg",...)If j contains the name for the file, jpeg(file=j, ...) should work. I guess you do not have jpeg support if calling your script in non-interactive mode, because you need X11 active. See ?jpeg. Uwe Ligges> i tried to use paste and as.character, but neither worked out the way i > want it to. > > thanks for any advice, Lars Claussen > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html
Hi
the following works for me:
j <- "box"
z <- "plot"
jpeg(file=paste("YOURPATH",j,z,".jpg", sep = ""))
boxplot(rnorm(100))
dev.off()
Regards,
Christoph Buser
--------------------------------------------------------------
Christoph Buser <buser at stat.math.ethz.ch>
Seminar fuer Statistik, LEO C13
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-44-632-4673 fax: 632-1228
http://stat.ethz.ch/~buser/
--------------------------------------------------------------
Lars writes:
> Hey,
>
> I'm generating a .jpeg file for a web application passing parameters
to
> R via cgi. R gets the parameters by using commandArgs, which are passed
> to a variable named j and z
>
> j<-commandArgs()[3]
> z<-commandArgs()[4]
>
> Later I want to use the characters strings of the argument which the
> variables are holding for my filename, e.g.:
>
> jpeg(file="d:/data/images/jz.jpeg",...)
>
> i tried to use paste and as.character, but neither worked out the way i
> want it to.
>
> thanks for any advice, Lars Claussen
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html