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.

______________________________________________
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.

Reply via email to