[R] Dimension of quantile function output

Jun Shen jun.shen.ut at gmail.com
Fri Jan 22 21:31:54 CET 2016


Dear list,

Say I have some quantile operation like this

data.frame(ID=rep(1:10,each=10),CONC=runif(100)) -> test

lapply(c('mean','sd','quantile'), function(x)
aggregate(test['CONC'],by=test['ID'],FUN=x)) -> temp

The output temp is a list of three elements. I would like to merge the
three elements into one data frame. The first two elements (the mean and sd
output) are easy to handle that I just need to update the column names. The
problem is the third element. Although it looks like a data frame in
dimension of 10 by 6 but really is just 10 by 2. How do I coerce the third
element in 10 by 6? Thanks a lot.

Jun


> head(temp[[3]])  ID     CONC.0%    CONC.25%    CONC.50%    CONC.75%   CONC.100%
1  1 0.024352714 0.235039202 0.662819513 0.737295381 0.934520832
2  2 0.004732985 0.246812366 0.399628344 0.663579348 0.942850115
3  3 0.240309454 0.445094065 0.593619958 0.815292642 0.985080817
4  4 0.070251047 0.173052744 0.591731071 0.706560762 0.929560236

	[[alternative HTML version deleted]]



More information about the R-help mailing list