[R] weighted m-estimator

Daniel Metzler daniel.metzler at gmx.net
Thu Dec 8 09:50:45 CET 2005

Dear R listers,

I'm trying use Huber's m-estimator on a dataset, which works fine so  

In the next step I would like to assign a (frequency) weight to the  
It seemed straight forward to me to replicate the rows according to  
their count variable.

Unfortunately,  a solution provided by jim holtman on Wed 19 Oct 2005  
in this list doesn't work for me:

 > y <- unlist(lapply(seq(nrow(x)), function(.row)rep(.row, x$count 
# replicate the row numbers
 > y
 > result <- x[y,] # pick out the rows
 > result$count <- 1 # set the count to 1
 > result

R keeps crashing. I presume because of 800,000 rows, which should be  

Does a smarter solution exist for weighting the observations  
according to their frequency than manually replicating rows when  
using the huber function?

Thanks for any help!

Daniel Metzler

More information about the R-help mailing list