This tween fills out NA
elements (or NULL
elements if data
is a list)
by interpolating between the prior and next non-missing values.
tween_fill(data, ease)
A data.frame or vector.
A character vector giving valid easing functions. Recycled to
match the ncol of data
If data
is a data.frame then a data.frame with the same
columns. If data
is a vector then a vector.
# Single vector
tween_fill(c(1, NA, NA, NA, NA, NA, 2, 6, NA, NA, NA, -2), 'cubic-in-out')
#> [1] 1.000000 1.018519 1.148148 1.500000 1.851852 1.981481 2.000000
#> [8] 6.000000 5.500000 2.000000 -1.500000 -2.000000
# Data frame
tween_fill(mtcars[c(1, NA, NA, NA, NA, 4, NA, NA, NA, 10), ], 'cubic-in')
#> mpg cyl disp hp drat wt qsec vs am
#> 1 21.00000 6 160.0000 110.0000 3.900000 2.620000 16.46000 0.000 1.000
#> 2 21.00320 6 160.7840 110.0000 3.893440 2.624760 16.48384 0.008 0.992
#> 3 21.02560 6 166.2720 110.0000 3.847520 2.658080 16.65072 0.064 0.936
#> 4 21.08640 6 181.1680 110.0000 3.722880 2.748520 17.10368 0.216 0.784
#> 5 21.20480 6 210.1760 110.0000 3.480160 2.924640 17.98576 0.512 0.488
#> 6 21.40000 6 258.0000 110.0000 3.080000 3.215000 19.44000 1.000 0.000
#> 7 21.36562 6 256.5875 110.2031 3.093125 3.218516 19.42219 1.000 0.000
#> 8 21.12500 6 246.7000 111.6250 3.185000 3.243125 19.29750 1.000 0.000
#> 9 20.47187 6 219.8625 115.4844 3.434375 3.309922 18.95906 1.000 0.000
#> 10 19.20000 6 167.6000 123.0000 3.920000 3.440000 18.30000 1.000 0.000
#> gear carb
#> 1 4.000000 4.000000
#> 2 3.992000 3.976000
#> 3 3.936000 3.808000
#> 4 3.784000 3.352000
#> 5 3.488000 2.464000
#> 6 3.000000 1.000000
#> 7 3.015625 1.046875
#> 8 3.125000 1.375000
#> 9 3.421875 2.265625
#> 10 4.000000 4.000000