> one approach is to use reshape(), e.g.,
>
> # suppose that 'dat' is your data.frame, then
> res <- reshape(dat, direction = "wide", idvar = "Q", timevar = "S")
> res[is.na(res)] <- 0
> res

You can also use the reshape package:

library(reshape)
datm <- melt(dat, id=1:2)
cast(datm, Q ~ S)

See the introduction to reshape
(http://www.had.co.nz/reshape/introduction.pdf) for more details and
examples.

Hadley

______________________________________________
[email protected] 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.

Reply via email to