[R] Question with apply function

Noah Silverman noah at smartmediacorp.com
Wed Aug 5 23:45:44 CEST 2009


In my continuing quest to generate some summary data, I've come across 
some useful suggestions in pasts posts.

The apply operation returns an error, and I can't figure out why.

Can someone help me fix this?

testlogdata <- cbind(testlogdata, range_group=cut(testlogdata$lrm_score, 
breaks=c(.9, .8, .7, .6, .5, .4, .3, .2, .1)))
apply(testlogdata, 2, function(x){tapply(x, 
list(testlogdata$range_group), mean)})

 From my understanding, this should generate a nice table with rows for 
each "break" and a mean of each column for that break.

Instead, I get a table full of NA.

Any ideas?

Thanks!

-N




More information about the R-help mailing list