dplyr summarise_each 与 na.rm [英] dplyr summarise_each with na.rm

查看:22
本文介绍了dplyr summarise_each 与 na.rm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法指示dplyr 使用summarise_eachna.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)))

这篇关于dplyr summarise_each 与 na.rm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆