What does `it doesn't work' actually mean? Please read the posting guide and follow its advice.
Also, please show us readable and properly indented code, using spaces consistently. (There is a chapter in `Writing R Extensions' showing you how to do this.) I just cannot parse your code, and suspect you cannot either.
On Sun, 14 Nov 2004, Laura Quinn wrote:
Hi,
I'm having a mental block as to how I can automatically assign filenames to the output of the following code. I am wishing to create a separate .png file for every image created, each of them having a sequential filename ie "sourcefile_index.png" so that I can create a movie from them.
Please could someone tell me where I am going wrong?
the following code works fine and outputs to screen:
fun_pca_vector_movie_plot<-function(x,y,z,t){ zz=seq(1,(nrow(x)-t),by=t);jj=seq(t+1,(nrow(x)),by=t) for(i in seq(along=zz)){ pca<-prcomp(x[zz[i]:jj[i],], retx=T, center=T,scale=T) { par(mfrow=c(1,z)) for(i in 1:z){ image(east,north,t(map.matrix),col=my.colors,axes=T, xlab="",ylab="") text(y[,3],y[,2],labels=as.character(y[,1])) title(paste("Component",i,"Step:")) arrows(y[,3],y[,2],(y[,3]+50*(pca$rotation[i,1:(ncol(x)/2)])), (y[,2]+50*(pca$rotation[i,((ncol(x)/2)+1):(ncol(x))])), angle=30,length=0.05,code=2) } box() } }}
but when I try to save to file as follows it doesn't work:
fun_pca_vector_movie_plot<-function(x,y,z,t){ zz=seq(1,(nrow(x)-t),by=t);jj=seq(t+1,(nrow(x)),by=t) for(i in seq(along=zz)){ pca<-prcomp(x[zz[i]:jj[i],], retx=T, center=T,scale=T) { par(mfrow=c(1,z)) for(i in 1:z){ plot.new() png(file=(paste(x".",i,"_",zz,".png",sep="")),width=240,height=240) image(east,north,t(map.matrix),col=my.colors,axes=T, xlab="",ylab="") text(y[,3],y[,2],labels=as.character(y[,1])) title(paste("Component",i,"Step:")) arrows(y[,3],y[,2],(y[,3]+50*(pca$rotation[i,1:(ncol(x)/2)])), (y[,2]+50*(pca$rotation[i,((ncol(x)/2)+1):(ncol(x))])), angle=30,length=0.05,code=2) dev.off() } box() } }}
many thanks in advance! Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT
tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED]
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
-- Brian D. Ripley, [EMAIL PROTECTED] 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
