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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 1 Apr 2002, dstierman wrote:> 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?Yes. The function you want is called paste(), not cat(). -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 1 Apr 2002, dstierman wrote:> I am having problems trying to create file names using the cat function. II think you meant the paste() function.> 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._