R/main_Ipaper.R

Defines functions set_dimnames set_dim which.notna last

Documented in set_dim set_dimnames

`%||%` <- function (x, y) {
  if (is.null(x)) 
    y
  else x
}

last <- function(x) x[[length(x)]]

which.notna <- function(x) which(!is.na(x))


#' Set dimensions of an Object
#'
#' @inheritParams base::dim
#' @param dim integer vector, see also [base::dim()]
#'
#' @seealso [base::dim]
#'
#' @examples
#' x <- 1:12
#' set_dim(x, c(3, 4))
#' @export
set_dim <- function(x, dim) {
  dim(x) <- dim
  x
}

#' @inheritParams base::dimnames
#'
#' @export
#' @rdname set_dim
set_dimnames <- function(x, value) {
  dimnames(x) <- value
  x
}

Try the rtrend package in your browser

Any scripts or data that you put into this service are public.

rtrend documentation built on Nov. 10, 2022, 6:14 p.m.