Skip to contents

Takes a numeric vector and will return a vector of one of the following:

  • "sin"

  • "cos"

  • "tan"

  • "sincos" This will do value = sin(x) * cos(x)

Usage

hai_hyperbolic_vec(.x, .scale_type = c("sin", "cos", "tan", "sincos"))

Arguments

.x

A numeric vector

.scale_type

A character of one of the following: "sin","cos","tan","sincos"

Value

A numeric vector

Details

Takes a numeric vector and will return a vector of one of the following:

  • "sin"

  • "cos"

  • "tan"

  • "sincos"

This function can be used on it's own. It is also the basis for the function hai_hyperbolic_augment().

Author

Steven P. Sanderson II, MPH

Examples

suppressPackageStartupMessages(library(dplyr))

len_out <- 25
by_unit <- "month"
start_date <- as.Date("2021-01-01")

data_tbl <- tibble(
  date_col = seq.Date(from = start_date, length.out = len_out, by = by_unit),
  a = rnorm(len_out),
  b = runif(len_out)
)

vec_1 <- hai_hyperbolic_vec(data_tbl$b, .scale_type = "sin")
vec_2 <- hai_hyperbolic_vec(data_tbl$b, .scale_type = "cos")
vec_3 <- hai_hyperbolic_vec(data_tbl$b, .scale_type = "sincos")

plot(data_tbl$b)
lines(vec_1, col = "blue")
lines(vec_2, col = "red")
lines(vec_3, col = "green")