#' @name matToPyArray
#' @title cat code to create numpy array
#' @param X matrix
#' @return NULL
#' @export
matToPyArray <- function(X) {
stopifnot(is.matrix(X))
bracCollapse <- function(x) sprintf("[%s]", paste(x, collapse = ","))
rows <- bracCollapse(apply(X, 1, bracCollapse))
cat(sprintf("np.array(%s)", rows))
NULL
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.