[R] Matrix::solve() with 1-d arrays

Deepayan Sarkar deep@y@n@@@rk@r @end|ng |rom gm@||@com
Fri Apr 16 08:04:20 CEST 2021


I get what I initially thought was unexpected behaviour from:

x <- tapply(runif(100), sample(5, 100, TRUE), mean)
solve(Diagonal(5), x)
# Error: not-yet-implemented method for solve(<ddiMatrix>, <array>).
#  ->>  Ask the package authors to implement the missing feature.

This is because x is a 1-D array, so the operation is not
well-defined. Would it make sense for Matrix to support this (treat
1-D arrays as column vectors, as it does for plain vectors)? Or should
I make my intent clear with

solve(Diagonal(5), as.vector(x))

?

-Deepayan



More information about the R-help mailing list