trhermes
2008-Apr-29 16:04 UTC
[R] Concatenate variables and quoted text for output filenames
I am outputting some graphs from SpatStat using a for loop. I want the png files to include the i and j from the nested loops in their names. For example, I want the file names to look like "i-j_plot.png". The code is below: ma <- levels(marks(X)) n <- length(ma) for(i in 1:n) for(j in 1:n) { png(filename=????) plot(envelope(X, Kcross, i=ma[i], j=ma[j])) dev.off() } -- View this message in context: http://www.nabble.com/Concatenate-variables-and-quoted-text-for-output-filenames-tp16963770p16963770.html Sent from the R help mailing list archive at Nabble.com.
Wolfgang Huber
2008-Apr-29 16:17 UTC
[R] Concatenate variables and quoted text for output filenames
29/04/2008 17:04 trhermes a ?crit> I am outputting some graphs from SpatStat using a for loop. I want the png > files to include the i and j from the nested loops in their names. For > example, I want the file names to look like "i-j_plot.png". The code is > below: > > ma <- levels(marks(X)) > n <- length(ma) > for(i in 1:n) > for(j in 1:n) > { > png(filename=????) > plot(envelope(X, Kcross, i=ma[i], j=ma[j])) > dev.off() > }png(filename=sprintf("%d-%d_plot.png", i, j)) -- Best wishes Wolfgang ------------------------------------------------------------------ Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber