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

后端 未结 6 757
难免孤独
难免孤独 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:46

    if your column contain any value that you want to neglect. it will help you

    ## da is data frame & Ozone is column name 
    
    ##for single column
    mean(da$Ozone, na.rm = TRUE)  
    
    ##for all columns
    colMeans(x=da, na.rm = TRUE)
    

提交回复
热议问题