[R] Warning while subsetting using Matrix package

From: Thaden, John J <ThadenJohnJ_at_uams.edu>
Date: Thu 06 Jul 2006 - 14:53:02 EST


Hello,
  Could someone please explain the following warning while subsetting in the Matrix package?
Thanks,
John Thaden, PhD
U. Arkansas for Med. Sci.
Little Rock AR USA

> # In the Matrix package...
> library("Matrix")
> # ...I had previously created a sparse matrix in triplet form:
> str(x)
Formal class 'dgTMatrix' [package "Matrix"] with 6 slots

  ..@ i       : int [1:923636] 1 2 3 4 5 6 7 8 9 10 ...
  ..@ j       : int [1:923636] 1 1 1 1 1 1 1 1 1 1 ...
  ..@ Dim     : int [1:2] 600 4482
  ..@ Dimnames:List of 2
  .. ..$ : chr [1:601] "50" "51" "52" "53" ...
  .. ..$ : chr [1:4482] "1" "2" "3" "4" ...
  ..@ x       : num [1:923636] 50.2 51.2 52.2 53.2 54.2 ...
  ..@ factors : list()

>
> # While subsetting x, I was surprised to get this warning:
> y<-x[1:300,]
Warning message:
number of items to replace is not a multiple of replacement length
> # I did not get a warning, however, if I were more explicit...
> y <- x[1:300,1:4482]
>
> # Of course with a standard matrix, neither form gives a warning:
> (z <- matrix(1:12,4))

     [,1] [,2] [,3]

[1,]    1    5    9
[2,]    2    6   10
[3,]    3    7   11
[4,]    4    8   12

> z[1:2,]
[1,] 1 5 9
[2,] 2 6 10
> z[1:2,1:4]
[1,] 1 5 9
[2,] 2 6 10
> # I wonder what is going on?

Confidentiality Notice: This e-mail message, including any a...{{dropped}}



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 Received on Thu Jul 06 15:01:26 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 06 Jul 2006 - 16:14:47 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.