[R] Matrix problems
Adaikalavan Ramasamy
gisar at nus.edu.sg
Thu Mar 20 13:30:58 CET 2003
It 'unwraps' the 200,000 x 2 matrix into a vector with 400,000
elements and giving you the location/subscripts of this vector that
matches the criterion. Instead you should use
apply(mat1, 2, function(y) which( y == 2 ))
which gives you the rows in each column that corresponds to 185.
Try length(mat1) and dim(mat1) and you will see that for length(), it
coerces the object into a vector first.
-----Original Message-----
From: Mmarques INESC [mailto:mmarques at inescporto.pt]
Sent: Thursday, March 20, 2003 7:49 PM
To: R-help Mailing list.
Subject: [R] Matrix problems
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 ... >
which(mat1 == 185)
[1] 1 201920 203792 205211 206604 220417 223767 225169 239420
243768 249351 249395 252077
What could be happening ?
Thanks in advance
Mark Marques
______________________________________________
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