I have a list of data frames whose dimensions are smaller than data frames in a second list. I would like to left merge them and then interpolate, to fill in the missing values. I have tried using smooth.spline() but this doesn't work with the NA's. Any suggestions?
Reprex
x <- tibble::tibble(
x = 1:9,
y = 1
)
y <- tibble::tibble(
x = c(1,3,5,6,9),
alpha = c(2,7,4,2,8)
)
z = dplyr::left_join(x = x, y = y)
z %>% dplyr::mutate(
beta = stats::smooth.spline(x = alpha, spar = 0.5)$y
)
I think its very difficult to advise you without context.
the alpha seems rather random, and doesnt seem like there would be reasonable imputations to be made for a cubic spline, I would expect in most cases something like midpoint linear interpolation to be a reasonable guess.
This looks great, except I am trying to avoid repeated values. My data represents sea level elevation at times throughout history but I only have data for certain time points. I am trying to load this data into a model but the behavior of sea level elevation changes is likely smooth rather than a step-function pattern.
I have a 2 list with 23 data frames for the data I am working with, sort of. I am working to wrangle one list from characters vectors into dbl formatted tibble's, and then I will have the two lists. from there I was going to: