Hi Lanna, What you're describing can be easily done via the reshape package: # test data data <- data.frame(year = factor(2001:2010), location = gl(2, 5), type = gl(10, 1), species = gl(5, 2), freq = rbinom(10, 1, .5) ) library(reshape) data <- melt(data) data2 <- cast(data, year + location + type ~ species, fill = 0) Cheers
Etienne Lalibert? ================================ School of Forestry University of Canterbury Private Bag 4800 Christchurch 8140, New Zealand Phone: +64 3 366 7001 ext. 8365 Fax: +64 3 364 2124 www.elaliberte.info