poly_add_columns {polypoly} | R Documentation |
Add orthogonal polynomial columns to a dataframe
Description
Add orthogonal polynomial columns to a dataframe
Usage
poly_add_columns(
.data,
.col,
degree = 1,
prefix = NULL,
scale_width = NULL,
na_values = c("error", "warn", "allow")
)
Arguments
.data |
a dataframe |
.col |
a bare column name |
degree |
number of polynomial terms to add to the dataframe |
prefix |
prefix for the names to add to the dataframe. default is the
name of |
scale_width |
optionally rescale the dataframe using |
na_values |
How to handle missing values. Default is |
Value
the dataframe with additional columns of orthogonal polynomial terms
of .col
Examples
df <- data.frame(time = rep(1:5, 3), y = rnorm(15))
# adds columns "time1", "time2", "time3"
poly_add_columns(df, time, degree = 3)
# adds columns "t1", "t2", "t3 and rescale
poly_add_columns(df, time, degree = 3, prefix = "t", scale_width = 1)
[Package polypoly version 0.0.3 Index]