[R] behaviour of rows and colomns suppression in a matrix

Sarah Goslee sarah.goslee at gmail.com
Thu Mar 13 16:59:17 CET 2014


On Thu, Mar 13, 2014 at 11:51 AM, Olivier ETERRADOSSI
<olivier.eterradossi at mines-ales.fr> wrote:
> Thank you Sarah,
>
> But no, I was not expecting this. For me integer(0) is not 0.
> That's why I finally tested length(unused.rows), which is 0 when
> unused.rows is integer(0).

Also from

?"["

i, j, ...: indices specifying elements to extract or replace.  Indices
          are 'numeric' or 'character' vectors or empty (missing) or
          'NULL'.  Numeric values are coerced to integer as by
          'as.integer' (and hence truncated towards zero).  Character
          vectors will be matched to the 'names' of the object (or for
          matrices/arrays, the 'dimnames'): see 'Character indices'
          below for further details.

So yes, in this case 0 is treated as integer(0).

When you have problems that seem odd to you, carefully reading the
relevant help is always a good place to start.

Sarah




More information about the R-help mailing list