[R] Matrix problems

Göran Broström gb at stat.umu.se
Thu Mar 20 13:04:21 CET 2003


On Thu, 20 Mar 2003, Mmarques INESC wrote:

> Hi all.
> I do not know if it is a bug in the windows version but i have this
> problem.
> Reading a file with 200000 rows, 2 columns and transforming into a
> 200000 x 2 matrix.
> If I try to find an element by using the which command which gives
> some correct indexes plus some others passing the 200000 row
> boundaries.
> If I try to reach those "outbound" indexs I get an "Error: subscript out
> of bounds" .
> Is this a limitation of matrix function ? or am i doing something
> wrong ?
> Example :
> 
>  > str(mat1)
>  num [1:200000, 1:2] 185 212 222 269 342 349 361 367 397 423 ...

>   [1]      1 201920 203792 205211 206604 220417 223767 225169 239420 243768 249351 249395 252077
>  What could be happening ?
>  > which(mat1 == 185)
mat1 is a matrix 200000x2 but also a vector of length 400000. Try

> ?which

and

> which(mat1 == 185, arr.ind = TRUE)

Göran
---
 Göran Broström                    tel: +46 90 786 5223
 Department of Statistics          fax: +46 90 786 6614
 Umeå University                   http://www.stat.umu.se/egna/gb/
 SE-90187 Umeå, Sweden             e-mail: gb at stat.umu.se



More information about the R-help mailing list