##
x <- matrix(c(1, 0, 0, 2, 1, NA), nrow = 3)
x
s <- as.simple_triplet_matrix(x)
col_tsums(s, c(1,2,1))
z <- col_tsums(s, c(1,2,1), na.rm = TRUE)
z
## check
zz <- col_tsums(as.matrix(s), c(1,2,1), na.rm = TRUE)
identical(zz, as.matrix(z))Run the code above in your browser using DataLab