View source: R/e_linear_interpolation.R
e_linear_interpolation | R Documentation |
If all y are NA, then return y. If all non-NA y values are equal, then impute all y values equal. Otherwise, find at least two non-NA missing values to impute internal, starting, or ending NAs, in that order.
e_linear_interpolation(
y,
x = NULL,
sw_which = c("all", "internal", "head", "tail")[1],
sw_extrapolation = c("martingale", "linear")[1]
)
y |
response values to impute via linear interpolation |
x |
spacing between y values |
sw_which |
switch to indicate which missing values to replace: "all", "internal", "head" (starting), or "tail" (ending) |
sw_extrapolation |
switch to indicate how to extrapolate to head and tail missing values. "martingale" sets NAs to closest non-NA value, while "linear" performs a linear extrapolation from the two closest non-NA values. |
y Completed list of numbers
e_linear_interpolation(y = c(NA, NA, NA, NA, NA))
e_linear_interpolation(y = c(NA, NA, NA, 4, NA))
e_linear_interpolation(y = c(1, NA, 3, NA, 5))
e_linear_interpolation(y = c(1, NA, NA, NA, 5), x = c(1, 2, 4, 8, 16))
e_linear_interpolation(y = c(NA, NA, NA, 4, 5), x = c(1, 2, 4, 8, 16), sw_extrapolation = "linear")
e_linear_interpolation(y = c(NA, NA, 3, 4, NA), x = c(1, 2, 4, 8, 16), sw_which = "head")
e_linear_interpolation(y = c(NA, "a", NA, 3, 4, NA)) # warning for not numeric
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.