# NOT RUN {
mat <- matrix(0, 3, 3)
idx <- c(1, 2)
# Typically, given matrix and row-column indices as two-element vector, we should do it like this:
mat[idx[1], idx[2]]
mat[idx[1], idx[2]] <- 8
# Using `at`, we can do it simplier!
at(mat, idx)
at(mat, idx) <- 7
mat
at(mat, idx)
# }
Run the code above in your browser using DataLab