[R] max.col weirdness
bolker at ufl.edu
Fri May 29 00:03:58 CEST 2009
Daryl Morris wrote:
> Sorry, I was too hasty. I see that the tolerance is in the
> documentation (and that "random" is the default tie-breaker).
> Would it be possible to allow tolerance to be a parameter?
> thanks, Daryl
Could you just use apply(x,1,which.max) ?
> x <- matrix(c(112345.568,112345.569,112345.567),1)
[,1] [,2] [,3]
[1,] 112345.6 112345.6 112345.6
It will presumably be less efficient than max.col (which
is implemented in C), and will automatically
pick the first value of the maximum if there are ties, but
should be OK for everyday use?
PS oddly enough apply(x,1,which.max) is faster -- maybe because
it doesn't try to deal with ties?
test replications user.self sys.self elapsed user.child
2 apply(x, 1, which.max) 50000 7.649 0.456 8.110 0
1 max.col(x) 50000 11.185 0.580 11.828 0
View this message in context: http://www.nabble.com/max.col-weirdness-tp23769831p23770927.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help