[Rd] cbind/rbind fail on matrixes containing lists (PR#6702)
Warnes, Gregory R
gregory_r_warnes at groton.pfizer.com
Wed Mar 31 20:54:27 CEST 2004
Hello Brian,
> -----Original Message-----
> From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
>
> There are no `matrixes containing lists'. There are lists
> which are also
> matrices, but their contents are the vector elements (unless
> you meant
> that it was a list of lists, which seems not be the case in
> your example).
> In the absence of a reproducible example, it is not clear to
> me exactly
> what you want to do.
>
> Here is a list matrix example:
>
> A <- matrix(as.list(1:4), 2, 2)
> cbind(A, A)
>
I was, in fact, using a matrix containing "list" elements.
I did fail to provide the definition of my 'list matrix'. It was simply:
> m1 <- matrix(list(NA),4,4)
> m1
[,1] [,2] [,3] [,4]
[1,] NA NA NA NA
[2,] NA NA NA NA
[3,] NA NA NA NA
[4,] NA NA NA NA
> class(m1)
[1] "matrix"
> class(m1[1,1])
[1] "list"
> cbind(m1,m1)
Error in cbind(...) : cannot create a matrix from these types
> rbind(m1,m1)
Error in rbind(...) : cannot create a matrix from these types
> It appears to be intentional (line 950 of bind.c and the actual cbind
> code), in which case this is a documentation bug and I have
> altered the
> docs.
Odd.
> Why not class(m1)? It should be the same ....
But it is not:
> class(m1)
[1] "matrix"
> class(m1[1,1])
[1] "list"
-Greg
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}
More information about the R-devel
mailing list