2
mylist2<-list(as.numeric(c(1:20)),(c(1:20)**2),sqrt(c(1:20)))

iData<-data.frame(do.call(cbind,mylist2))

print(iData,row.names=FALSE)

quantile(iData$X1,iData$X2,iData$X3,c(0.25,0.25,0.25))

I want to display these column combined vectors its first quartile, but I am stuck on this

4

1 回答 1

4

如果您尝试分别获取每列的分位数,我建议使用该dplyr包:

library(dplyr)
iData %>%  summarize_all( ~ quantile(.x, probs = 0.25))

或等效地

summarize_all(iData, ~ quantile(.x, probs = 0.25))

基本方法将使用sapply

sapply(iData, function(x) quantile(x, probs = 0.25))
于 2018-06-30T04:44:50.760 回答