我想使用几列来分割我的数据框,并fivenum在每个组上调用let .
aggregate(Petal.Width ~ Species, iris, function(x) summary(fivenum(x)))
Run Code Online (Sandbox Code Playgroud)
返回的值是一个只有2列的data.frame,第二个是矩阵.如何将其转换为data.frame的普通列?
更新
我希望使用更少的代码,如下所示 fivenum
ddply(iris, .(Species), summarise,
Min = min(Petal.Width),
Q1 = quantile(Petal.Width, .25),
Med = median(Petal.Width),
Q3 = quantile(Petal.Width, .75),
Max = max(Petal.Width)
)
Run Code Online (Sandbox Code Playgroud)