Skip to content

error-prone feature?

2 messages · Khamenia, Valery, Brian Ripley

#
Hi All,

  while looking why the cclust(cclust) doesn't work for 1-dimensional data,
  I've found unpleasant behavior in semantics of R. Indeed:

    is.matrix(matrix(cbind(c(1,2,3,4)),ncol=2)[1:2,])  == TRUE

  but:

    is.matrix(matrix(c(1,2))[1:2,]) == FALSE
  

kind regards,
Valery A.Khamenya
---------------------------------------------------------------------------
Bioinformatics Department
BioVisioN AG, Hannover
#
Well, that is in all good texts on R, together with the 
solution: drop=FALSE.  See ?"[" for the on-line details.

`S Programming' says

  S programmers have often overlooked these rules, which can result
  in puzzling or incorrect behaviour when just one observation or
  variable meets some selection criterion.

I suggest you get yourself a copy and read it.
On Thu, 15 May 2003, Khamenia, Valery wrote: