Mean of a column in a data frame, given the column's name

后端 未结 6 764
难免孤独
难免孤独 2020-11-30 01:13

I\'m inside a big function I have to write. In the last part I have to calculate the mean of a column in a data frame. The name of the column I am operating on is given as a

6条回答
  •  余生分开走
    2020-11-30 01:57

    Use summarise in the dplyr package:

    library(dplyr)
    summarise(df, Average = mean(col_name, na.rm = T))
    

    note: dplyr supports both summarise and summarize.

提交回复
热议问题