[R] problems with max.col()

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Apr 24 18:36:28 CEST 2003


heberto ghezzo wrote:
> Hello, I think the following qualify as a bug
> given:
> x<-c(1,2,3,4,2,4,2,2,4,2,2,2,4,3,2,1)
> z<-embed(x,4)
> z
>       [,1] [,2] [,3] [,4]
>  [1,]    4    3    2    1
>  [2,]    2    4    3    2
>  [3,]    4    2    4    3
>  [4,]    2    4    2    4
>  [5,]    2    2    4    2
>  [6,]    4    2    2    4
>  [7,]    2    4    2    2
>  [8,]    2    2    4    2
>  [9,]    2    2    2    4
> [10,]    4    2    2    2
> [11,]    3    4    2    2
> [12,]    2    3    4    2
> [13,]    1    2    3    4
> 
> max.col(z)
>  [1] 1 2 3 4 3 1 2 3 4 1 2 3 4
> Why?     ^ ^
> 
>>       1 2
> 
> or should be
>  [1] 1 2 3 4 3 4 2 3 4 1 2 3 4
> i.e. the first column with the max, or the last column
> same if
> z <- embed(x,5)
>  max.col(z)
>  [1] 2 1 2 5 1 5 3 4 1 2 3 4
> where it should be either of:
>  2 1 2 3 1 2 3 4 1 2 3 4
>  2 3 4 5 4 5 3 4 5 2 3 4
> or I am missing something?

Reading the word "random" in its help file:

"Find the maximum position for each row of a matrix, breaking ties at 
random."


You observed another bug: The Compiled HTML help file (on Windows) 
doesn't come up with ?max.col. Nevertheless, brosing through the index 
results in a working link (and a page).

I'm not sure whether the bug is in R or in Microsoft's help compiler ...
I will take a look later (and move the thread to R-devel in case of 
further investigations).

Uwe Ligges


> ?max.col does not return anything
> R 1.7.0 on Win98
> .
> Heberto.Ghezzo at McGill.ca
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help



More information about the R-help mailing list