#' @name as_matrix
#' @aliases as_matrix
#'
#' @title converts to matrix
#'
#' @description converts sparse matrix to normal matrix for sparse data
#'
#' @param mat
#'
#' @return matrix
as_matrix <- function(mat){
tmp <- matrix(data=0L, nrow = mat@Dim[1], ncol = mat@Dim[2])
row_pos <- mat@i+1
col_pos <- findInterval(seq(mat@x)-1,mat@p[-1])+1
val <- mat@x
for (i in seq_along(val)){
tmp[row_pos[i],col_pos[i]] <- val[i]
}
row.names(tmp) <- mat@Dimnames[[1]]
colnames(tmp) <- mat@Dimnames[[2]]
return(tmp)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.