impute.linear | R Documentation |
This function imputes missing entries in a numeric vector by linear interpolation.
impute.linear(x)
x |
a numeric data vector, where |
A missing entry will be imputed by linear interpolation with the two nearest values before and after it in the vector. When all the values before (after) it are missing, use the two nearest values after (before) it, instead.
a new numeric vector, with the same size of the original vector, while all the missing entries have been imputed.
Yong He, Xinbing Kong, Lorenzo Trapani, Long Yu
a=c(NA,NA,3,NA,NA,6,NA,NA)
b=c(1,2,3,4.5,5,NA,6.5,7,NA)
impute.linear(a)
impute.linear(b)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.