[R] reshape data, adding rows to dataframe
Lucia Rueda
lucia.rueda at ba.ieo.es
Wed Feb 2 14:06:31 CET 2011
Thanks Henrique!
It solves the problem of having the column "N" with unreal number of
individuals since N=1
with Petr's example:
expand <- transform(dat[rep(1:nrow(dat), times=dat$N), ] ,N=1)
rownames(expand) <- NULL
expand
> expand
animal N
1 a 1
2 a 1
3 b 1
4 c 1
5 c 1
6 c 1
Cheers!
--
View this message in context: http://r.789695.n4.nabble.com/reshape-data-adding-rows-to-dataframe-tp3253640p3254038.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list