用na.rm总结一下 [英] dplyr summarise_each with na.rm
本文介绍了用na.rm总结一下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法指示 dplyr
使用 summarise_each
与 na.rm = TRUE
?我想采用 summarise_each(mean)
的变量的平均值,但是我不知道如何指定它来忽略缺少的值。
Is there a way to instruct dplyr
to use summarise_each
with na.rm=TRUE
? I would like to take the mean of variables with summarise_each("mean")
but I don't know how to specify it to ignore missing values.
推荐答案
按照文档中的链接,您似乎可以使用 funs(mean(。,na.rm = TRUE))
:
Following the links in the doc, it seems you can use funs(mean(., na.rm = TRUE))
:
library(dplyr)
by_species <- iris %>% group_by(Species)
by_species %>% summarise_each(funs(mean(., na.rm = TRUE)))
这篇关于用na.rm总结一下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文