search for: l_pct

Displaying 1 result from an estimated 1 matches for "l_pct".

Did you mean: _pct
2011 Apr 30
1
More flexible aggregate / eval
...<- data.frame(id, ids, group1, group2, group3) df <- rbind(df, df, df) df$time <- seq(2009, 2011, each=3) df$x1 <- sample(0:100, 63) df$x2 <- sample(44:234, 63) head(df) ## For group1 d1 <- aggregate(cbind(x1, x2) ~ group1 + ids + time, data = df, sum) d1$l_pct <- with(d1, ave(x1, list(group1, time), FUN = function(x) round(prop.table(x) * 100, 1) ) ) op1 <- xtabs(l_pct ~ group1 + ids + time, data = d1) ftable(op1, row.vars=c(1,3)) ## For group2 d2 <- aggregate(cbind(x1, x2) ~ group2 + ids + time, data =...