[R] Relative frequency of cases in data frame matching a specified criteria
Stefan Björk
stefan.bjork at gmail.com
Fri Jan 23 12:05:06 CET 2009
I want to get the relative frequency of cases in a data frame that
matches a specified criteria, omiting NA values. This seem so simple,
but I can't come up with an effective way.
nrow(data[data$variable>value & !is.na(data$variable),])/nrow(data)
works but is very ineffective and CPU consuming when the data frame is
large (more than 13000 rows and 400 columns).
/S
More information about the R-help
mailing list