Created
August 5, 2013 16:52
-
-
Save markmfredrickson/6157476 to your computer and use it in GitHub Desktop.
How to look at submatrices of InfinitySparseMatrix objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(optmatch) | |
example(match_on) | |
#' @param x An ISM or blocked ISM | |
#' @param rs Names of rows to keep | |
#' @param cs Names of columns to keep | |
submatrix <- function(x, rs, cs) { | |
subset(x, | |
x@rownames %in% rs, | |
x@colnames %in% cs) | |
} | |
myr <- c("B", "F") | |
myc <- c("I", "d") | |
# non-blocked matrix: | |
as.matrix(submatrix(match_on.examples$pscal, myr, myc)) | |
# blocked matrix: | |
as.matrix(submatrix(match_on.examples$ps3, myr, myc)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment