inflate {mefa} | R Documentation |
This function inflates a data frame according to a column containing integers, by repeating each rows as many times as the integer value. This is an internal function used by the function xcount
converting an object of 'sscount' into 'xcount'.
inflate(factors, count)
factors |
a data frame or matrix used. Rows in factors are repeated as many times as the value of
respective value of count . Thus, number of rows in factor must equal the length of count . |
count |
a numeric (integer) vector with the same length as number of rows in factors . |
A matrix with columns as in factors
, and rows according to sum of count
.
Peter Solymos, Solymos.Peter@aotk.szie.hu, http://www.univet.hu/users/psolymos/personal/
ss <- data.frame( cbind( c("sample1","sample1","sample2","sample2","sample3","sample4"), c("species1","species1","species1","species2","species3","zero.count"), c("male","female","male","female","male","male") ), c(1, 2, 10, 3, 4, 1) ) colnames(ss) <- c("sample.id", "species.id", "gender", "catch") inflate(ss[,1:3], ss[,4]) inflate(ss[,1:3], c(1:6)) inflate(ss[,1:3], rep(2, 6))