0
votes

I'd like to construct a bigger diagonal matrix from a vector. I installed the bigalgebra package, but it don't have the diag function. In addition, how to make the inverse (solve) and transpose (t) to big matrices.

v <- runif(42109)
V <- diag(v)
Error: cannot allocate vector of size 13.2 Gb
1

1 Answers

1
votes

If sparse matrices are an option, you can use the Matrix package (supplied with R).

library(Matrix)
V <- Matrix(0, nrow=42109, ncol=42109)
diag(V) <- v