fill_table: Find non-reported dates and fill them with 'NA_*'

View source: R/ff_fill_table.R

fill_tableR Documentation

Find non-reported dates and fill them with NA_*

Description

Automatically finds non recorded date periods and fills them with NA_real_ values.

Usage

fill_table(x, col_name = "all", by = NULL)

Arguments

x

data frame (or tibble) with class Date or POSIX* in the first column.

col_name

string with column(s) name(s) to fill.

by

string with a valid time step (e.g.: "month", "day", "6 hour", "3 hour", "1 hour", "15 min").

Value

A data frame (or tibble) with the date and the filled numeric variable(s).

Examples


# let's use a synthetic example to illustrate the use of the function
dates <- seq.Date(from = as.Date('1980-01-01'),
                 to = as.Date('2020-01-01'), by = 'day' )
var   <- runif(n = length(dates), min = 0, max = 100)

met_var <- data.frame(date = dates, random = var)[-c(50:100, 251, 38) , ]

met_var_fill <- fill_table(x = met_var, by = 'day')



hydrotoolbox documentation built on April 14, 2023, 12:34 a.m.