Skip to content

any suggestions on this error?

3 messages · onyourmark, Uwe Ligges, Bill Venables

#
Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow =
nr,  : 
  invalid 'ncol' value (too large or NA)

the statement was:
for (i in v) {for (j in m[0,]){if(v[i]==m[0,j]){M[,-j]}}} 


where 'v' is a vector, and 'm' and 'M' are both matrices.
#
onyourmark wrote:
That code does not make sense at all:

- What is m[0,] ? Note that R starts counting at 1 ...
- You action is  "M[,-j]", but that doe snot do anything except for 
internally returning that matrix into the empty space.

So, if you tell us what you are really going to do, we might be able to 
help better.


Uwe Ligges
#
You have use a zero index.  This is not allowed in R (normally).

Also your code, even if corrected, would do nothing so I suspect your problems do not stop there.  

Did you really mean "for(i in v) .... if(v[i] ... "?  Very subtle if you did. 


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of onyourmark
Sent: Saturday, 2 May 2009 2:19 PM
To: r-help at r-project.org
Subject: [R] any suggestions on this error?


Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow =
nr,  : 
  invalid 'ncol' value (too large or NA)

the statement was:
for (i in v) {for (j in m[0,]){if(v[i]==m[0,j]){M[,-j]}}} 


where 'v' is a vector, and 'm' and 'M' are both matrices.