[Rd] several bugs (PR#918) lists and matrices
Thomas Lumley
tlumley@u.washington.edu
Mon, 23 Apr 2001 15:51:48 -0700 (PDT)
On 24 Apr 2001, Peter Dalgaard BSA wrote:
> Thomas Lumley <tlumley@u.washington.edu> writes:
>
> > This is a more difficult question. You can't put a list into a matrix.
> > Matrices handle homogenous data; they are vectors with a dimension
> > attribute. Lists with an arbitrary dimension attribute are, as Rob
> > pointed out, an unimplemented bug.
>
> Ummm. I'd have to say that it is an implemented bug if a bug at all.
> tapply() does this all the time (although most often by accident), and
> is even documented to do so. If one can have a list with a dim(), not
> being able to index such a beast does look like a bug to me...
Strange. I had assumed that an array of mode list looked like a vector of
LISTSXPs, but it seems that it looks like a list with dimensions.
You can index it, with [[]]
> a<-list(1,2,3,4)
> dim(a)<-c(2,2)
> a
[,1] [,2]
[1,] "Numeric,1" "Numeric,1"
[2,] "Numeric,1" "Numeric,1"
> a[2,1]
[[1]]
NULL
> a[[2,1]]
[1] 2
which is weird. The question is then what a[2,1] thinks it's returning.
You still can't stick a list into an array of numbers, which is what Rich
needs, and is better handled with data frames.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._