Wesley Roberts | 20 Aug 12:33
Picon

pdf filenames in while loop

Dear R users,

I am a remote sensing researcher currently studying the use of LiDAR data for quantifying tree height, in
particular I would like to determine the sample size needed to capture and quantify canopy height
variability. To do this I have employed the use of automap(), which automatically calculates variograms
including reporting the range of the variogram. The program is easy to use and I have had much success with
it. However, I have run into a  slight problem. My analysis consists of 60 independent plots located in our
study area and I wish to run the variogram analyses for each plot and then write the resulting plot to a pdf
file. Given that I have 60 plots I would like to vary the name of each file based on the plot being processed,
see my code below. I have tried a number of different ap
 proaches using the paste() command but cant seem to get it to work.

Currently, as.character does not seem to solve the problem

pdf(file="as.character(paste(f.mat[a])).pdf")

alternatively I could write out to JPEG but I would rather not take that approach or I could write all pdf
plots to one file but I am not sure how to do this.

Could someone suggest a solution?

I am using R version 2.7.1 (2008-06-23) on Ubuntu 7.10.

Many thanks,
Wesley

library(gstat)
library(automap)

## List of files to be used in the while loop
(Continue reading)

Barry Rowlingson | 20 Aug 13:34
Picon

Re: pdf filenames in while loop

2008/8/20 Wesley Roberts <wroberts <at> csir.co.za>:
> Dear R users,

> pdf(file="as.character(paste(f.mat[a])).pdf")

Whoa! Why the quotes? And why the as.character? Just paste:

 pdf(file=paste(f.mat[a],".pdf",sep=""))

 should do it. It looks like you were trying to create a file called
"as.character(...etc".

Barry

______________________________________________
R-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Gmane