[R] Weighted median for matrices

From: Jakob Petersen <jakob.petersen_at_qmul.ac.uk>
Date: Thu 31 Mar 2005 - 20:57:33 EST

I am working with a matrix (x),

where rows are non-overlapping geographical areas (postcodes; here denoted with letter row names),

and columns are income bands with a central value (e.g. 7.5k, here denoted x1,x2, etc.).

The data are counts (how many households with 0-5k pa, 5-10k pa?, etc.)  

I would like to summarise this data set.

First row-wise as suggested by Henrik Bengtsson (www.maths.lth.se/help/R/R.classes/
<http://www.maths.lth.se/help/R/R.classes/> ), example:  

library (R.basic)

x<-cbind(x1=3,x2=c(4:1,2:5))

dimnames(x)[[1]]<-letters[1:8]

w<-c(1,2)

wm <- apply(x, MARGIN=1, FUN=weighted.median, w=w, na.rm=TRUE)

wm  

QUESTION
Secondly, I would like to aggregate rows (postcodes) into bigger units according additional factor vectors (higher administrative order or environmental attributes).

I would be grateful for ideas to how I can achieve this in our R.  

Jakob  

Software:

R ver 2.01 (Windows)

R.basic ver 0.59  

Jakob Petersen

GISc student (MSc)

Birkbeck, University of London



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Mar 31 21:11:54 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:57 EST