R/helper.R

Defines functions simulate extdata_file add_phi

Documented in extdata_file

# add_phi ----------------------------------------------------------------------
add_phi <- function(df, period_length, dbg = FALSE)
{
  kwb.utils::setColumns(
    df,
    phi = 2 * pi * kwb.utils::selectColumns(df, "day_number") / period_length,
    dbg = dbg
  )
}

# extdata_file -----------------------------------------------------------------

#' Get Path to File in This Package
#'
#' @param \dots parts of path passed to \code{\link{system.file}}
#' @export
extdata_file <- function(...) {
  system.file("extdata", ..., package = "kwb.heatsine")
}

# simulate ---------------------------------------------------------------------
simulate <- function(model, day_number, period_length, ...)
{
  predict(
    model,
    newdata = add_phi(tibble::tibble(day_number = day_number), period_length),
    ...
  )
}
KWB-R/kwb.heatsine documentation built on Oct. 22, 2020, 12:37 a.m.