[R] creating an output file name using cat

Thomas Lumley tlumley at u.washington.edu
Mon Apr 1 23:16:03 CEST 2002


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list