| datePad | R Documentation |
Expand a dataframe that contains a 'date' column to a regular sequence of timestamps between specified start and end dates. The function can operate in two modes:
fill = FALSE: simply complete the sequence at the target interval.
fill = TRUE: regularise the data at the native interval to create
explicit blocks, then expand to the target interval and carry the block's
values forward so that intra-block timestamps inherit the block's measured
value (block-filling behaviour).
datePad(
mydata,
type = NULL,
interval = NULL,
start.date = NULL,
end.date = NULL,
fill = FALSE,
print.int = FALSE,
...
)
mydata |
Data.frame or tibble containing at least a 'date' column (Date or POSIXt). |
type |
|
interval |
|
start.date |
Optional start date/time. If |
end.date |
Optional end date/time. If |
fill |
Logical; when |
print.int |
Logical; when |
... |
Passed to |
The function detects the native input interval automatically if interval is
not supplied, supports grouping via type, and preserves timezones for
POSIXt date columns.
A dataframe expanded to the requested sequence with values filled according to 'fill'. The returned object preserves the 'date' column type and timezone (for POSIXt).
df <- mydata[-c(2, 4, 7), ] # Remove some rows to create gaps
datePad(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.