na_trim: Trim Leading/Trailing Missing Observations

Description Usage Arguments Value See Also Examples

View source: R/na_trim.R

Description

Generic function for removing leading and trailing NAs.

Usage

1
na_trim(object, ...)

Arguments

object

an object.

...

further arguments passed to methods.

sides

character specifying whether NAs are to be removed from both sides, just from the left side or just from the right side.

is.na

If "any" then a row will be regarded as NA if it has any NAs. If "all" then a row will be regarded as NA only if all elements in the row are NA. For one dimensional zoo objects this argument has no effect.

Value

An object in which leading and/or trailing NAs have been removed.

See Also

na_approx, na_contiguous, na_locf, na_omit, na_spline, stinterp, zoo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# examples of na_trim
x <- zoo(c(1, 4, 6), c(2, 4, 6))
xx <- zoo(matrix(c(1, 4, 6, NA, 5, 7), 3), c(2, 4, 6))
na_trim(x)
na_trim(xx)

# using na_trim for alignment
# cal defines the legal dates
# all dates within the date range of x should be present
cal <- zoo(,c(1, 2, 3, 6, 7))
x <- zoo(c(12, 16), c(2, 6))
na_trim(merge(x, cal))
 

decisionpatterns/na.actions documentation built on Aug. 25, 2020, 8:04 p.m.