Skip to content
Back to formatted view

Raw Message

Message-ID: <4768E19B.8090204@geo.uzh.ch>
Date: 2007-12-19T09:17:15Z
From: Martin Tomko
Subject: median of binned values

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