[R] data.frame to array?

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Fri Apr 3 22:22:26 CEST 2009


David Winsemius wrote:
> I do not think that the form [[1:3]] is legit.

sure it is. 

>
> > ltest <- list( "a", "b", "c", "d")
> > ltest[[1:3]]
> Error in ltest[[1:3]] : recursive indexing failed at level 2

read the error message:  *recursive* indexing failed.  that's because
ltest[[1]] has only one element while you wanted its second element (and
that element's third element).

    ltest = list(list(2, as.list(1:3)))
    ltest[[1:3]]
    # 3

is just fine.

vQ




More information about the R-help mailing list