Re: [R] Relative frequency of cases in data frame matching a specified criteria

2009-01-23 Thread Dimitris Rizopoulos
in this case you just need: mean(data$variable > value & !is.na(data$variable)) I hope it helps. Best, Dimitris Stefan Björk wrote: 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 wi

[R] Relative frequency of cases in data frame matching a specified criteria

2009-01-23 Thread Stefan Björk
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 w