expandData {matman} | R Documentation |
Expands a temporal data frame
Description
Expands a temporal data frame and fills values for missing dates.
Usage
expandData(
data,
expand,
expandTo = c("all", "event"),
valueColumns,
latest_values = F,
valueLevels = NA,
timestamp,
timestampFormat = c("day", "week", "month", "quarter", "year"),
keepData = T
)
Arguments
data |
Data frame that will be expanded. |
expand |
Name of the variables that will be expanded. |
expandTo |
Defines whether values for the variables to be expanded will be filled for all dates or only those dates included in the data. |
valueColumns |
Name of the columns that are filled with specific values. |
latest_values |
If True missing values are filled with the latest known value until the next known value comes in. |
valueLevels |
Specific values that are used to fill the value columns. If latest_values = TRUE only values with no known values in the past of this values are specified with this specific values. |
timestamp |
Name of the column including the timestamp. This column should be in Date , YY-mm, YYYY-'W'ww, YYYY-mm, YYYY-'Q'q or YYYY format. |
timestampFormat |
Declares in which format the timestamp comes in (i.e., "day", "week", "month", "quarter", "year"). |
keepData |
Defines whether variables that will not be expanded should be kept. |
Value
Returns the expanded data frame.
Author(s)
Leon Binder leon.binder@th-deg.de
Bernhard Bauer bernhard.bauer@th-deg.de
Michael Scholz michael.scholz@th-deg.de
See Also
Examples
data("Amount")
expandedItems = expandData(Amount,
expand = c("item", "itemgroup"),
expandTo = "all",
valueColumns = c("amount", "value"),
latest_values = TRUE,
valueLevels = c(0, 0),
timestamp = "date",
timestampFormat = "day")