Hi,
I apologize if this topic has been discussed - I could not figure out
a good search phrase for this question.

I have a named vector x, with multiple (duplicate) names, and I would
like to obtain a (shorter) vector with non-duplicate names in which
the values are the means of the values of the duplicated indexes in x.
My best (fastest) solution to this was this code:

nms <- names( x )
x.uniq <- sapply( unique( nms ), function( i ) mean( subtracted[ nms == i ] ) )

However, this takes forever on my beefy Mac Pro. Is there a faster way
to this using pre-written functions in R?

Thanks a lot for any advice.
-David

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to