[R] median of binned values

From: Martin Tomko <martin.tomko_at_geo.uzh.ch>
Date: Wed, 19 Dec 2007 10:17:15 +0100


Dear list,
I have a vector (array, table row, whatever is best) of frequency values for categories (or bins), and I need to find the median category. Trivial to do by hand, but I was wondering if there is a means to do it in R in an elegant way.

The obvious medioan(vector) returns the median frequency for the binns, and that is not what I want. i.e,:

             freq
cat1 1
cat2 10
cat3 100

cat4 1000
cat5 10000

I want it to return cat5, instead of cat3.

Thanks a lot
Martin



R-help_at_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. Received on Wed 19 Dec 2007 - 09:21:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 19 Dec 2007 - 10:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.