On 01.11.2010 11:38, Henrik Pärn wrote:
Dear all, # 1. I use tapply to calculate various things based on a grouping variable. # simple example using the warpbreaks dataset: tmp <- with(warpbreaks, tapply(breaks, tension, range)) tmp dimnames(tmp) # 2. I wish to plot the result of each element of tmp, using the names of the elements in tmp as 'main' in each plot # My attempt: # par(mfrow = c(3, 1)) # my preferred 'par' in this case. lapply(tmp, function(x) plot(x, main = dimnames(x)))
x in your anomymous function does not have any dimnames (since it it the corresponding element of tmp. Hence go with a loop or use
lapply(seq_along(tmp), function(x) plot(tmp[[x]], main = names(tmp[x]))) Uwe Ligges
Apparently not the right way to extract dimnames to main. Any suggestion of how to proceed? Thanks in advance for any comments. Henrik
______________________________________________ R-help@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.