Your assertion that xtabs did not work on subsetted data seems suspect. Please provide an example so we can show you what you did wrong or R can be fixed.
I suspect that you need to learn more about how and when to use factors, since removing all instances of a particular level doesn't automatically remove that level from the factor. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. RobinLovelace <rob...@hotmail.com> wrote: Hi David Winsemius, thanks a lot for the answer that I finally spotted amongst my verbose message. Many thanks, and I see that it does work now: I had to change the variable names of the subset HHum02 because all the rows from main dataset were still there invisibly (after I used subset to remove them). For this reason the xtabs solution did not appear to work. Having saved the output table, then loaded it again, the xtabs solution works perfectly. another solution (when HHum02 is replaced by Humn02) is: mdata <- melt(Humn02) Denormal <- cast(mdata, CASW~CO2Group~variable, sum) Check out the power of the reshape package here: http://had.co.nz/reshape/ Many thanks again, Robin -- View this message in context: http://r.789695.n4.nabble.com/Denormalize-data-tp3729817p3730137.html Sent from the R help mailing list archive at Nabble.com. _____________________________________________ 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. [[alternative HTML version deleted]] ______________________________________________ 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.