interpolate
Syntax
interpolate(X, [method='linear'], [limit], [inplace=false],
[limitDirection='forward'], [limitArea])
Arguments
X is a numeric vector.
-
linear: for NULLs surrounded by valid values, fill the NULLs linearly. For NULLs outside valid values, fill the NULLs with the closest valid values.
-
pad: fill NULL values with existing values.
-
nearest: fill NULL values with the closest valid values.
-
krogh: fill NULL values with krogh polynomials.
limit is a positive integer indicating the maximum number of consecutive NULL values to fill.
inplace is a Boolean value indicating whether to update the input vector array. The default value is false, which means a new vector will be returned.
limitDirection is a string indicating the direction to fill NULL values. It can take the following values: 'forward', 'backward' and 'both'. The default value is 'forward'.
limitArea is a string indicating restrictions regarding filling NULL values. It can take the following values and the default value is empty string "".
-
empty string: no restrictions.
-
inside: only fill NULLs surrounded by valid values.
-
outside: only fill NULLs outside valid values.
Details
Fill the NULL values in a vector.
Examples
a=[NULL,NULL,1,2,NULL,NULL,5,6,NULL,NULL];
interpolate(a);
// output
[,,1,2,3,4,5,6,6,6]
interpolate(X=a, method="pad");
// output
[,,1,2,2,2,5,6,6,6]
interpolate(X=a, limitDirection='both');
// output
[1,1,1,2,3,4,5,6,6,6]
interpolate(X=a, limit=1, limitDirection='both');
// output
[,1,1,2,3,4,5,6,6,]
interpolate(X=a, limitDirection='both', limitArea='outside');
// output
[1,1,1,2,,,5,6,6,6]
a;
// output
[,,1,2,,,5,6,,]
interpolate(X=a, limitDirection='backward', inplace=true);
// output
[1,1,1,2,3,4,5,6,,]
a;
// output
[1,1,1,2,3,4,5,6,,]