R/helpers.r

#' Get Vector of Boolean Values
#'
#' Get a vector of length n of boolean values
#' with the probablity of a \code{TRUE} being prob.
#' @param n number of boolean values
#' @param prob probablity of \code{TRUE}
#' @export
boolean_prob <- function(n, prob){
    as.logical(stats::rbinom(n, size = 1, prob = prob))
}


#' Create an invoice formated data frame
#'
#' Create the proper format given two vectors
#' @param item Item ID's
#' @param quantity order quantity
#' @importFrom dplyr data_frame
#' @export
invoice <- function(items, orders){
    data_frame(item = items, order_qty = orders)
}

max_id <- function(state, frame, id){
    ifelse(length(state[[c(frame, id)]]) > 0, max(state[[c(frame, id)]]), 1)
}
milumtextiles/itemsim documentation built on May 22, 2019, 11:54 p.m.