我有这个数据框tt:
structure(list(Hostname = structure(c(1L, 1L, 1L), .Label = "Server01", class = "factor"),
Date = structure(1:3, .Label = c("2015-10-01 08:15:00", "2015-10-01 08:30:00",
"2015-10-01 10:45:00"), class = "factor"), Cpubusy = c(35.2,
17.89, 22.04), Function = structure(c(1L, 1L, 1L), .Label = "Data Retriever", class = "factor")), .Names = c("Hostname",
"Date", "Cpubusy", "Function"), class = "data.frame", row.names = c(NA,
-3L))
我需要对Avg进行95分,并创建一个表格。
表格看起来应该是这样的:
Server AVG 95th_Percentile Function
Server01 10 30 Data Retriver
我试过这样的dplyr汇总函数:
cpu<-tt %>% group_by(Hostname) %>% summarise_(Mean = interp(~mean(Cpubusy, na.rm=FALSE)),Quantile= interp(~quantile(Cpubusy, prob=0.95,na.rm=FALSE)),tt$Function)
无法为每个服务器插入功能数据。我有什么想法可以做到这一点吗?
答案 0 :(得分:0)
我能够弄明白,如果有人遇到这个问题,你可以按多个字段进行分组。
这对我有用:
cpu<-tt %>% group_by(Hostname,Function) %>% summarise_(Mean = interp(~mean(Cpubusy, na.rm=FALSE)),Quantile= interp(~quantile(Cpubusy, prob=0.95,na.rm=FALSE)))