csv - How to take an average of a column while only considering the values greater than 300 in R -


i have dataframe containing values. want take average of each column want take consideration values greater or equal 300.

example: dataframe[,1]       100       200       250       300       300       400       400      average = 350. 

mean(ifelse(dataframe[,1] >= 300, dataframe[,1], na), na.rm = true) 

and columns @ once:

do.call("cbind", lapply(dataframe, function(x){mean(ifelse(x >= 300, x, na), na.rm = true)})) 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -