RE: [R] Matrix problems

About this list Date view Thread view Subject view Author view Attachment view

From: Adaikalavan Ramasamy (gisar@nus.edu.sg)
Date: Thu 20 Mar 2003 - 23:30:58 EST


Message-id: <024D6AEFCB92CB47BA1085751D184BB80105F230@MBXSRV03.stf.nus.edu.sg>


  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@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@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:25 EST