View source: R/augment-hai-polynomial.R
hai_polynomial_augment | R Documentation |
This function takes in a data table and a predictor column. A user can either create
their own formula using the .formula
parameter or, if they leave the default of
NULL
then the user must enter a .degree
AND .pred_col
column.
hai_polynomial_augment(
.data,
.formula = NULL,
.pred_col = NULL,
.degree = 1,
.new_col_prefix = "nt_"
)
.data |
The data being passed that will be augmented by the function. |
.formula |
This should be a valid formula like 'y ~ .^2' or NULL. |
.pred_col |
This is passed |
.degree |
This should be an integer and is used to set the degree in the poly function. The degree must be less than the unique data points or it will error out. |
.new_col_prefix |
The default is "nt_" which stands for "new_term". You can set this to whatever you like, as long as it is a quoted string. |
A valid data.frame/tibble must be passed to this function. It is required that
a user either enter a .formula
or a .degree
AND .pred_col
otherwise this
function will stop and error out.
Under the hood this function will create a stats::poly()
function if the
.formula
is left as NULL
. For example:
.formula = A ~ .^2
OR .degree = 2, .pred_col = A
There is also a parameter .new_col_prefix
which will add a character string
to the column names so that they are easily identified further down the line.
The default is 'nt_'
An augmented tibble
Steven P. Sanderson II, MPH
Other Augment Function:
hai_fourier_augment()
,
hai_fourier_discrete_augment()
,
hai_hyperbolic_augment()
,
hai_scale_zero_one_augment()
,
hai_scale_zscore_augment()
,
hai_winsorized_move_augment()
,
hai_winsorized_truncate_augment()
suppressPackageStartupMessages(library(dplyr))
data_tbl <- data.frame(
A = c(0, 2, 4),
B = c(1, 3, 5),
C = c(2, 4, 6)
)
hai_polynomial_augment(.data = data_tbl, .pred_col = A, .degree = 2, .new_col_prefix = "n")
hai_polynomial_augment(.data = data_tbl, .formula = A ~ .^2, .degree = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.