You could also try:
library(plyr)
newdf <- function(.data, ...) {
eval(substitute(data.frame(...)), .data, parent.frame())
}
x1 <- ddply(mtcars,.(cyl,gear), newdf, mgp=t(quantile(mpg)),hp=t(quantile(hp)))
#(found in one of the google group discussions)
#or
library(data.table)
dt1 <- data.
Hi,
Try:
do.call(data.frame,c(x,check.names=FALSE))
A.K.
Hello,
I´m using function aggregate in R 3.0.2. If I run the instruction
x<-aggregate(cbind(mpg,hp)~cyl+gear,data=mtcars,quantile) I get the
result the following data.frame:
cyl
gear
mpg.0%
mpg.25%
mpg.50%
mpg.75%
Daniel,
You can see better what is going on if you look at
as.list(x)
There you can see that cyl and gear are vectors but mpg and hp are matrices.
You can rearrange them using the do.call() function
x2 <- do.call(cbind, x)
dim(x2)
Jean
On Fri, Nov 1, 2013 at 7:08 AM, Daniel Fernandes wrote:
Hello,
I´m using function aggregate in R 3.0.2. If I run the instruction
x<-aggregate(cbind(mpg,hp)~cyl+gear,data=mtcars,quantile) I get the
result the following data.frame:
cyl
gear
mpg.0%
mpg.25%
mpg.50%
mpg.75%
mpg.100%
hp.0%
hp.25%
hp.50%
hp.75%
hp.100%
4
3
21.5
21.5
4 matches
Mail list logo