On Aug 5, 2009, at 5:45 PM, Noah Silverman wrote:

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)})

I think you're close -- are you sure you should be making a list out of your testlogdata$range_group in your call to tapply?

Here's another way to kind of doing the same ... might need some tweaking, but:

apply(testlogdata, 2, function (x) lapply(split(x, testlogdata $range_group), mean)

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to