# COMMON #######################################################################
# =============================================================================.
#' ** RESERVED FOR INTERNAL USE **
# -----------------------------------------------------------------------------.
#' @keywords internal
#' @export
m2v <- function(i, j, nrow) {
(j - 1) * nrow + i
}
# =============================================================================.
#' ** RESERVED FOR INTERNAL USE **
# -----------------------------------------------------------------------------.
#' @keywords internal
#' @export
v2m <- function(x, nrow) {
j <- (x - 1) %/% nrow + 1
i <- (x - 1) %% nrow + 1
x <- cbind(i, j)
attributes(x) <- attributes(x)[1] # remove auto-generated dimnames
x
}
# =============================================================================.
#' ** RESERVED FOR INTERNAL USE **
# -----------------------------------------------------------------------------.
#' @keywords internal
#' @export
AddByRow <- function(m, v) {
m + rep(v, rep(dim(m)[1], dim(m)[2]))
}
# =============================================================================.
#' ** RESERVED FOR INTERNAL USE **
# -----------------------------------------------------------------------------.
#' @keywords internal
#' @export
MulByRow <- function(m, v) {
m * rep(v, rep(dim(m)[1], dim(m)[2]))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.