[R] data.frame's and [2, c(T, F)] in R 2.6.0

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Mon Oct 8 16:58:29 CEST 2007


data-ploner.com wrote:
> In R prior to 2.6.0 with matrizes as well as with data.frames it is  
> possible to do:
>
> a[2, c(TRUE, FALSE)]
>
> In R 2.6.0 the mixed indexing works only for matrizes. Is this the  
> intention, a bug, or did I get something wrong?
> Best regards
>
> Meinhard
>
>   
It looks unintentional, but it is not due to "mixed indexing":

> a[TRUE,c(TRUE,FALSE)]
Error in .subset2(xx, j) : attempt to select less than one element
> a[2,c(TRUE,TRUE)]
  a b
2 2 5

As far as I can tell, It happens only when drop=TRUE and exactly one
column is selected using a logical index.

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list