我有一个如下所示的数据框:
#df
ID DRUG FED AUC0t Tmax Cmax
1 1 0 100 5 20
2 1 1 200 6 25
3 0 1 NA 2 30
4 0 0 150 6 65
Run Code Online (Sandbox Code Playgroud)
答案等等.我想总结药物DRUG和FED状态的AUC,Tmax和Cmax的一些统计数据FED.我用dplyr.例如:对于AUC:
CI90lo <- function(x) quantile(x, probs=0.05, na.rm=TRUE)
CI90hi <- function(x) quantile(x, probs=0.95, na.rm=TRUE)
summary <- df %>%
group_by(DRUG,FED) %>%
summarize(mean=mean(AUC0t, na.rm=TRUE),
low = CI90lo(AUC0t),
high= CI90hi(AUC0t),
min=min(AUC0t, na.rm=TRUE),
max=max(AUC0t,na.rm=TRUE),
sd= sd(AUC0t, na.rm=TRUE))
Run Code Online (Sandbox Code Playgroud)
但是,输出不按DRUG和FED分组.它只给出一行包含DRUG和FED中未分面的统计数据.
知道为什么吗?我怎样才能让它做正确的事情?