[Rd] Unexpected behaviour of x[i] when i is a matrix, on Windows

Peter Ehlers ehlers at ucalgary.ca
Fri Feb 12 19:12:00 CET 2010


You're comparing 2.10.0 on Windows with 2.11.0 on Linux.
Have you tried 2.11.0 on Windows? => same result as on Linux.

  -Peter Ehlers

Wolfgang Huber wrote:
> Hi,
> 
> when running the following on different instances of R (Linux and 
> Windows), I get different results. The one for Linux seems to be the 
> intended / documented one. When using numeric indices rather than 
> characters, Windows seemed to behave as expected.
> 
> -----------On Windows--------------
> 
> x = matrix(FALSE, nrow=3, ncol=3)
> colnames(x) = LETTERS[1:3]
> rownames(x) = letters[1:3]
> x
> 
> #       A     B     C
> # a FALSE FALSE FALSE
> # b FALSE FALSE FALSE
> # c FALSE FALSE FALSE
> 
> x [ cbind("b", "B") ] = TRUE
> x
>                                                           b     B
> # FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE
> 
> sessionInfo()
> 
> R version 2.10.0 (2009-10-26)
> i386-pc-mingw32
> 
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> 
> -----------On Linux--------------
> x = matrix(FALSE, nrow=3, ncol=3)
> colnames(x) = LETTERS[1:3]
> rownames(x) = letters[1:3]
> x
> #       A     B     C
> # a FALSE FALSE FALSE
> # b FALSE FALSE FALSE
> # c FALSE FALSE FALSE
> x [ cbind("b", "B") ] = TRUE
> x
> #       A     B     C
> # a FALSE FALSE FALSE
> # b FALSE  TRUE FALSE
> # c FALSE FALSE FALSE
> 
>  > sessionInfo()
> R version 2.11.0 Under development (unstable) (2010-02-12 r51125)
> x86_64-unknown-linux-gnu
> 
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
> 
> attached base packages:
> [1] stats     graphics  grDevices datasets  utils     methods   base
> 
> other attached packages:
> [1] fortunes_1.3-7
> 
> 
> 
> 

-- 
Peter Ehlers
University of Calgary



More information about the R-devel mailing list