Description Usage Arguments Value Author(s) Examples
Takes a dataframe with silent lost values and makes it explicit with NAs with the help
of a security interval defined by fInterval
.
1 | fortify_df(df, fInterval, by, names)
|
df |
a list of dataframes with a dates column in |
fInterval |
a 2-item vector with 'start' and 'end' POSIXct dates respectively. All and only all the values in the given interval will be explicitdly
included in the resulting dataframe, with NAs in case of missing observations in the input dataframe. By default the limit dates are extracted from the data, in this case 'start' and end'
its the minimun and maximun dates for all the dataframes given in |
by |
a character string, containing the data increment in terms of "sec", "min", "hour", "day", "DSTday", "week", "month", "quarter" or "year".
This can optionally be preceded by a (positive or negative) integer and a space, or followed by "s".
See |
names |
a vector of names for the dataframe values. If a character vector are not provided the columns will be renamed with capital letters. |
A fortified dataframe, i.e with all the lost values explicited. The resulting time index its perfectly
defined by seq(start,end,by)
, so the columns of the dataframe created with this function will have the same index,
i.e the silent lost values of the inputs dataframes (the columns in the new one) will be marked with NAs in the right positions.
JV Yago
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #One column dataframe with silent lost observations
start <- as.POSIXct("2019/01/01")
end <- as.POSIXct("2019/01/02")
dates <- seq(start, end, by = "hour")
df.simple <- data.frame(dates = dates[-(sample(1:25,5))], values=rep(1,20))
fortify_df(df=df.simple, by="hour")
#Multiple column dataframe with silent lost observations
df.complex <- data.frame(dates = dates[-(sample(1:25,5))],
A = 1:20, B = LETTERS[1:20],
C = rnorm(1:20))
fortify_df(df=df.complex, by="hour")
# Multiple datafrems with silent lost observations
df.A <- data.frame(dates = dates[-(sample(1:25,5))], a = 1:20)
df.B <- data.frame(dates = dates[-(sample(1:25,3))], a = 1:22)
df.C <- data.frame(dates = dates[-(sample(1:25,7))], a = 1:18)
fortify_df(list(df.A, df.B, df.C), by = "hour")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.