ts_na_omit: Omit NA values

Description Usage Arguments Details Value See Also Examples

View source: R/ts_na_omit.R

Description

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

Usage

1

Arguments

x

ts-boxable time series, an object of class ts, xts, zoo, 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.

Value

a ts-boxable time series, with the same class as the input.

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- AirPassengers
x[c(2, 4)] <- NA

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

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

# make NAs explicit
head(ts_regular(ts_df(x)))

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

Example output

sh: 1: timedatectl: Permission denied
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In system("timedatectl", intern = TRUE) :
  running command 'timedatectl' had status 126
2: In file(con, "r") : cannot open file '/etc/timezone': Permission denied
[1] 112  NA 132  NA 121 135
        time value
1 1949-01-01   112
2 1949-02-01    NA
3 1949-03-01   132
4 1949-04-01    NA
5 1949-05-01   121
6 1949-06-01   135
        time value
1 1949-01-01   112
2 1949-02-01    NA
3 1949-03-01   132
4 1949-04-01    NA
5 1949-05-01   121
6 1949-06-01   135
        time value
1 1949-01-01   112
2 1949-03-01   132
3 1949-05-01   121
4 1949-06-01   135
5 1949-07-01   148
6 1949-08-01   148

tsbox documentation built on April 30, 2020, 1:05 a.m.