[R] using dimnames as main when plotting with lapply

Henrik Pärn henrik.parn at bio.ntnu.no
Mon Nov 1 11:38:17 CET 2010


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)))




Apparently not the right way to extract dimnames to main. Any suggestion 
of how to proceed?

Thanks in advance for any comments.

Henrik


-- 
Henrik Pärn
Centre for Conservation Biology
Department of Biology
Norwegian University of Science and Technology
No-7491 Trondheim
NORWAY

Office: +47 735 96084
Mobile: +47 909 89 255
Fax: +47 735 96100



More information about the R-help mailing list