R/pos_wrap_x.R

Defines functions pos_wrap_x

Documented in pos_wrap_x

#' Title
#'
#' @inheritParams pos_wrap
#'
#' @return
#' @export
#'
#' @examples
#' pos_wrap_x()
#' pos_wrap_x(n = 12)
#' pos_wrap_x(snake = TRUE)
pos_wrap_x <- function(x0 = 0,
                   n = 5,
                   ncol = 3,
                   width = 1,
                   snake = FALSE){


  if(snake == TRUE){

    ifelse(((0:(n-1) %/% ncol) %% 2) == 1,
    ncol*width - (0:(n-1) %% ncol)*width + x0 - 1,
    (0:(n-1) %% ncol)*width + x0
    )

  } else{

    (0:(n-1) %% ncol)*width + x0

  }

}
EvaMaeRey/ggstamp documentation built on June 30, 2022, 11 p.m.