#' Transform a count matrix into a corpus data.frame
#'
#' @import magrittr
#' @importFrom magrittr %>%
#' @export
transform_count_matrix_to_corpus <- function(data){
if (is.null(colnames(data))) {
warning(
paste0("The column names (the features) were not provided.
Replacing them with 'w1'...'w",ncol(data),"'\n")
)
colnames(data) <- paste0("w", 1:ncol(data))
}
purrr::map_dfr(
.x = 1:nrow(data),
.f = function(i) {
rep(colnames(data), data[i,]) %>%
sample() %>% # for fun
stringr::str_c(., collapse = " ") %>%
tibble::as_tibble()
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.