A <- diag(3)
x <- 1:3
insert_matrix_column(A, x, 0)
insert_matrix_column(A, x, 1)
insert_matrix_column(A, x, 2)
insert_matrix_column(A, x, 3)
### also single value
x <- 2
insert_matrix_column(A, x, 0)
### also multiple positions
insert_matrix_column(A, x, 0:3)
### also trivial case
insert_matrix_column(matrix(nrow = 0, ncol = 0), integer(), integer())
Run the code above in your browser using DataLab