dismisc_extrapolate: Extrapolate (and interpolate) values

Description Usage Arguments Details Value

View source: R/dismisc-extrapolate.R

Description

Uses a spline or lm to extrapolate (and interpolate) values.

Usage

1
dismisc_extrapolate(x, y, xout = x, method = "natural")

Arguments

x

the independent variable; something like a time value

y

the dependent variable; something like a population value

xout

values to interpolate/extrapolate on, defaults to x

method

can be "lm" or any method in stats::spline()

Details

Use in a dplyr chain something like this to extrapolate (and interpolate) within city (for example):

df %<>% group_by(city) %>% mutate_at(total_population, funs(population_interpolated = dismisc_extrapolate(x=year,y=.)))

If there are no non-missing y values, a vector of NAs is returned.

Value

the values of the extrapolated function y(x) on domain xout


rdisalv2/dismisc documentation built on Nov. 2, 2021, 1:34 a.m.