Skip to content
Prev 55916 / 63424 Next

as.vector() broken on a matrix or array of type "list"

Hi,

Unlike on an atomic matrix, as.vector() doesn't drop the "dim"
attribute of matrix or array of type "list":

   m <- matrix(list(), nrow=2, ncol=3)
   m
   #      [,1] [,2] [,3]
   # [1,] NULL NULL NULL
   # [2,] NULL NULL NULL

   as.vector(m)
   #      [,1] [,2] [,3]
   # [1,] NULL NULL NULL
   # [2,] NULL NULL NULL

   is.vector(as.vector(m))
   # [1] FALSE

Thanks,
H.