R: How to apply a function to all the variables in a dataframe
# In this case we will count the number of non-missing cases of each variable in the dataframe "data": library(plyr) obs <- function(x) sum(!is.na(x)) colwise(obs)(data)