migue-s
8/4/2011 - 11:49 PM

R: How to apply a function to all the variables in a dataframe

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)