Learn R Programming

RSEIS (version 4.2-4)

fixNA: Fix NA values.

Description

Replace NA values in a time series with mean values between end points of missing segments, or first and last real values in case the NA's are at the beginning or ends of traces.

Usage

fixNA(y)

Value

numeric vector with no NA values.

Arguments

y

numeric vector

Author

Jonathan M. Lees<jonathan.lees@unc.edu>

Details

fixNA searches for stretches of NA 's in a time series and replaces the NA values with numeric values based ont he two end points of each section.

See Also

butfilt

Examples

Run this code

## source("~/Site/TA_DATA/CODE/fixNA.R")

### last samples are NA
zig = rnorm(25)
zig[10:15] = NA

noNA = fixNA(zig)

### first samples are NA
zig = rnorm(25)
zig[1:5] = NA
noNA = fixNA(zig)


zig = rnorm(25)
zig[1:5] = NA
zig[21:25] = NA

noNA = fixNA(zig)



zig = rnorm(25)
zig[1] = NA
zig[21:25] = NA
zig[10:12] = NA

noNA = fixNA(zig)
cbind(zig, noNA)




Run the code above in your browser using DataLab