#...............................................................................
#...............................................................................
# ADD ALIGN
#...............................................................................
#...............................................................................
#' @export
fable.add.align.column <- function(x, pos = 0, align = "center", DEBUG = FALSE) {
.fable.align.check(x, align)
attr(x,"ALIGN") <- add.col(attr(x,"ALIGN"),col = align, pos = pos, DEBUG = DEBUG)
x
}
#' @export
#' @rdname fable.add.align.column
fable.add.align.col <- fable.add.align.column
#' @export
fable.add.align.row <- function(x, pos = 0, align = "center", DEBUG = FALSE) {
.fable.align.check(x, align)
attr(x,"ALIGN") <- add.row(attr(x,"ALIGN"), row = align, pos = pos, DEBUG = DEBUG)
x
}
#...............................................................................
#...............................................................................
# SET ALIGN
#...............................................................................
#...............................................................................
#' @export
fable.set.align.col <- function(x,pos,align, DEBUG = FALSE) {
if (is.null(x)) stop("x must be set")
.fable.align.check(x, align)
attr(x,"ALIGN") <- set.col(attr(x,"ALIGN"), pos = pos, col = align, DEBUG = DEBUG )
x
}
#' @export
fable.set.align.row <- function(x,pos,align, DEBUG = FALSE) {
if (is.null(x)) stop("x must be set")
.fable.align.check(x, align)
attr(x,"ALIGN") <- set.row(attr(x,"ALIGN"), pos = pos, row = align, DEBUG = DEBUG )
x
}
#...............................................................................
#...............................................................................
# SET ALIGN --- SINGLE CELL
#...............................................................................
#...............................................................................
#' @export
fable.set.align.cell <- function(x,row,col,align, DEBUG = F) {
if (is.null(x)) stop("x must be set")
.fable.align.check(x, align)
attr(x,"ALIGN") <- set.cell(attr(x,"ALIGN"), row = row, col = col, item = align, DEBUG = DEBUG )
x
}
#...............................................................................
#...............................................................................
# SET ALIGN --- WHOLE MATRIX
#...............................................................................
#...............................................................................
#' @export
fable.set.align <- function(x,align = "right", DEBUG = FALSE) {
if (is.null(x)) stop("x must be set")
.fable.align.check(x, align)
attr(x,"ALIGN") <- fill.matrix(attr(x,"ALIGN") , item = align, DEBUG = DEBUG)
x
}
#...............................................................................
#...............................................................................
# ALIGN OPTIONS & CHECKS
#...............................................................................
#...............................................................................
.fable.align.check <- function(x, align) {
.fable.check(x)
.fable.check.align(align)
}
#' @export
fable.align.options <- function() {
return(c("left","right","center"))
}
#' @export
is.valid.fable.align <- function(align) {
if (is.null(align)) return(FALSE)
if (all(align %in% fable.align.options())) return(TRUE)
return(FALSE)
}
.fable.check.align <- function(align, stop.on.error = TRUE) {
if (!is.valid.fable.align(align)) {
m <- paste0("align must be one of: ",paste0(fable.align.options(), collapse = ","))
if (stop.on.error) stop(m)
message(m)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.