dplyr summarise_each with na.rm

后端 未结 5 1806
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 18:41

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 summaris

5条回答
  •  情书的邮戳
    2020-12-12 19:38

    summarise_at function in dplyr will summarise a dataset at specific column and allow to remove NAs for each functions applied. Take iris dataset and compute mean and median for variables from Sepal.Length to Petal.Width.

    library(dplyr)
    summarise_at(iris,vars(Sepal.Length:Petal.Width),funs(mean,median),na.rm=T)
    
    

提交回复
热议问题