[R] creating an output file name using cat

dstierman dstierman at micron.com
Mon Apr 1 22:51:44 CEST 2002


I am having problems trying to create file names using the cat function. I
have an array of column headers, called cnames[] that I want to use as part
of a jpeg output file. Here is the basic code I am using:

data<-read.csv("inputfile.txt")
cnames<-colnames(data)         
for(i in 9:dim(data)[2]) {     
	...
	jpeg(file=cat("data",cnames[i],".jpg",sep=""), width=800,
height=400, bg="white")
	...
}

I get the following error with this code:

R is cool->     jpeg(file=cat("data",cnames[i],".jpg",sep=""), width=800,
height=400, bg="white")

ERROR:
dataGL.jpgError in X11(paste("jpeg::", quality, ":", filename, sep = ""),
width,  : 
        unable to start device JPEG
In addition: Warning message: 
could not open JPEG file `' 

Does anyone have an idea on what is wrong?
Thanks, Don
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list