R/methods_collection.R
Collection-as.matrix.Rd
Turn a collection of fingerprints into a sparse binary matrix
# S4 method for Collection as.matrix(x, ...)
x | object of class 'Collection' that needs to be turned into a sparse binary matrix |
---|
object of class dgCMatrix (sparse binary matrix)
# NOT RUN { # Get data data("company_descriptions") # Retrieve texts txts <- lapply(company_descriptions, function(x) x$desc) # Fingerprint txts_fp <- do_fingerprint_document(txts) # Or you can turn them into a sparse binary matrix sbm <- as.matrix(txts_fp) # This matrix works in a similar way as normal matrices sbm[1:3, 1:8] # You can do operations such as apply, rowSums, colSums etc. dim(sbm) colsums <- apply(sbm, 2, sum) # }