Reputation: 197
Suppose we have a matrix A
of order k2*k
where k=k1+k2
such that k1=k-k2
. The characteristic of the matrix A
is such that first k1
columns are zero and remaining k2*k2
is an identity matrix. How to create such a customized matrix in R?
NOTE:
For smaller dimensions of k1
and k2
, it's easy. But I am looking for an automated command for handling larger dimensions of k1
and k2
.
Upvotes: 1
Views: 132
Reputation: 14987
k <- 20
k2 <- 15
k1 <- k - k2
diagonal <- diag(k2)
zeros <- matrix(0, nrow = k2, ncol = k1)
result <- cbind(zeros, diagonal)
Upvotes: 2