Skip to contents

Takes a numeric vector(s) or date and will return a tibble of one of the following:

  • "sin"

  • "cos"

  • "tan"

  • "sincos"

  • c("sin","cos","tan", "sincos")

Usage

hai_hyperbolic_augment(
  .data,
  .value,
  .names = "auto",
  .scale_type = c("sin", "cos", "tan", "sincos")
)

Arguments

.data

The data being passed that will be augmented by the function.

.value

This is passed rlang::enquo() to capture the vectors you want to augment.

.names

The default is "auto"

.scale_type

A character of one of the following: "sin","cos","tan", "sincos" All can be passed by setting the param equal to c("sin","cos","tan","sincos")

Value

A augmented tibble

Details

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

  • "sin"

  • "cos"

  • "tan"

  • "sincos"

  • c("sin","cos","tan", "sincos")

This function is intended to be used on its own in order to add columns to a tibble.

Author

Steven P. Sanderson II, MPH

Examples

suppressPackageStartupMessages(library(dplyr))

len_out <- 10
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)
)

hai_hyperbolic_augment(data_tbl, b, .scale_type = "sin")
#> # A tibble: 10 × 4
#>    date_col        a     b hyperbolic_b_sin
#>    <date>      <dbl> <dbl>            <dbl>
#>  1 2021-01-01  0.853 0.450            0.435
#>  2 2021-02-01 -0.405 0.973            0.827
#>  3 2021-03-01 -0.420 0.128            0.127
#>  4 2021-04-01  0.327 0.758            0.687
#>  5 2021-05-01  0.975 0.996            0.839
#>  6 2021-06-01 -0.832 0.768            0.695
#>  7 2021-07-01  1.99  0.670            0.621
#>  8 2021-08-01 -0.384 0.162            0.161
#>  9 2021-09-01 -1.09  0.989            0.835
#> 10 2021-10-01 -0.726 0.327            0.321
hai_hyperbolic_augment(data_tbl, b, .scale_type = "tan")
#> # A tibble: 10 × 4
#>    date_col        a     b hyperbolic_b_tan
#>    <date>      <dbl> <dbl>            <dbl>
#>  1 2021-01-01  0.853 0.450            0.484
#>  2 2021-02-01 -0.405 0.973            1.47 
#>  3 2021-03-01 -0.420 0.128            0.128
#>  4 2021-04-01  0.327 0.758            0.946
#>  5 2021-05-01  0.975 0.996            1.54 
#>  6 2021-06-01 -0.832 0.768            0.965
#>  7 2021-07-01  1.99  0.670            0.792
#>  8 2021-08-01 -0.384 0.162            0.163
#>  9 2021-09-01 -1.09  0.989            1.52 
#> 10 2021-10-01 -0.726 0.327            0.339