Releases: tjmahr/polypoly
Releases · tjmahr/polypoly
v0.0.3
release notes
-
poly_add_columns()
gains anna_values
argument for how to handle missing values. Default is"error"
to raise an error. Other options include"warn"
to ignore the missing values but raise a warning and"allow"
to silently accept the missing values. (#2)
demo of na_values
By default, poly_add_columns()
will "error"
when it encounters na_values
.
data <- mtcars
data$wt[c(1, 2, 6, 9)] <- NA_real_
polypoly::poly_add_columns(data, wt, 3)
#> Error in `polypoly::poly_add_columns()`:
#> ! NA values found in `wt`.
#> ℹ `stats::poly()` cannot handle missing values.
#> Backtrace:
#> ▆
#> 1. └─polypoly::poly_add_columns(data, wt, 3)
#> 2. └─rlang::abort(...)
polypoly::poly_add_columns(data, wt, 3, na_values = "error")
#> Error in `polypoly::poly_add_columns()`:
#> ! NA values found in `wt`.
#> ℹ `stats::poly()` cannot handle missing values.
#> Backtrace:
#> ▆
#> 1. └─polypoly::poly_add_columns(data, wt, 3, na_values = "error")
#> 2. └─rlang::abort(...)
poly_add_columns()
can "warn"
: We get a warning that missing values are present, but polynomials for the non-missing values are added.
data2 <- polypoly::poly_add_columns(data, wt, 3, na_values = "warn")
#> Warning: NA values found in `wt`.
#> ℹ `stats::poly()` cannot handle missing values, so those values will be ignored.
#> ℹ Derived columns like `wt1` will contain missing values.
# the three `wt1`, `wt2`, `wt3` have been added
colnames(data2)
#> [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear"
#> [11] "carb" "wt1" "wt2" "wt3"
# and they have NAs
round(data2$wt1, 3)
#> [1] NA NA -0.167 0.000 0.042 NA 0.066 -0.005 NA 0.042
#> [11] 0.042 0.159 0.096 0.105 0.378 0.411 0.396 -0.189 -0.298 -0.257
#> [21] -0.140 0.057 0.041 0.116 0.117 -0.238 -0.200 -0.317 -0.009 -0.083
#> [31] 0.066 -0.081
Finally, poly_add_columns()
can silently "allow"
missing values.
data3 <- polypoly::poly_add_columns(data, wt, 3, na_values = "allow")
round(data3$wt1, 3)
#> [1] NA NA -0.167 0.000 0.042 NA 0.066 -0.005 NA 0.042
#> [11] 0.042 0.159 0.096 0.105 0.378 0.411 0.396 -0.189 -0.298 -0.257
#> [21] -0.140 0.057 0.041 0.116 0.117 -0.238 -0.200 -0.317 -0.009 -0.083
#> [31] 0.066 -0.081
Created on 2022-10-20 with reprex v2.0.2
First CRAN release
- Same features as before: Tidying, plotting, rescaling, column-binding of polynomial matrices.
- Added
poly_plot_data()
which returns the dataframe that would be plotted bypoly_plot()
.
First version
First initial version.
Main features:
- plotting
- tidying
- column-binding
- rescaling