impute.linear {OLCPM} | R Documentation |
impute missing entries by linear interpolation
Description
This function imputes missing entries in a numeric vector by linear interpolation.
Usage
impute.linear(x)
Arguments
x |
a numeric data vector, where |
Details
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.
Value
a new numeric vector, with the same size of the original vector, while all the missing entries have been imputed.
Author(s)
Yong He, Xinbing Kong, Lorenzo Trapani, Long Yu
Examples
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)
[Package OLCPM version 0.1.2 Index]