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:
> 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
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595