Learn R Programming

tsbox (version 0.4.1)

ts_na_omit: Omit NA values

Description

Remove NA values in ts-boxable objects, turning explicit into implicit missing values.

Usage

ts_na_omit(x)

Value

a ts-boxable object of the same class as x, i.e., an object of class ts, xts, zoo, zooreg, data.frame, data.table, tbl, tbl_ts, tbl_time, tis, irts or timeSeries.

Arguments

x

ts-boxable time series, an object of class ts, xts, zoo, zooreg, data.frame, data.table, tbl, tbl_ts, tbl_time, tis, irts or timeSeries.

Details

Note that internal NAs in ts time series will not be removed, as this conflicts with the regular structure.

See Also

ts_regular, for the opposite, turning implicit into explicit missing values.

Examples

Run this code
x <- AirPassengers
x[c(2, 4)] <- NA

# A ts object does only know explicit NAs
ts_na_omit(x)

# by default, NAs are implicit in data frames
ts_df(x)

# make NAs explicit
ts_regular(ts_df(x))

# and implicit again
ts_na_omit(ts_regular(ts_df(x)))

Run the code above in your browser using DataLab