na2mean: Replace NA in a vector by mean of neighboring values.

Description Usage Arguments Details Value Author(s) Examples

Description

This method replaces NA-Values in a vector by the mean of the neighboring values. Example: c(1,NA,3) is converted to c(1,2,3).

Usage

1

Arguments

x

Vector to fill

Details

The method does not work if multiple NA are in sequence.

Value

Vector with NA replaced by mean.

Author(s)

Dominik Reusser

Examples

1
2
na2mean(c(1,NA,2))
na2mean(c(1,NA,NA,2))

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

[1] 1.0 1.5 2.0
[1]  1 NA NA  2

fast documentation built on May 2, 2019, 5:56 a.m.