Here's an example:
t <- list(a=1,b=2,c=3)
typeof(as.matrix(t))
If you run this in R (i'm using ubunutu R version 4.3.1), the typeof is still list. And if you make a matrix like matrix(c(1,2,3), ncol=3) the typeof would return matrix. For another function, I require the type to be a matrix and it's throwing an error otherwise.
I'm not sure if this is a bug or an intended feature but I'd love if someone could explain what's going on. I know I can solve this by calling unlist() and matrix() but I'd be interested to know why this is happening and if perhaps there's some easier way to solve this
as has been discussed in the commens as.matrix is using as.matrix.default method in both cases.
We can chase the differences down further but perhaps its enough to recognise that the base::array function treats a named list input differently to a named vector input.