| vintages_wide | R Documentation |
Converts a vintages dataset from long format to wide format, optionally
grouping by id if present. The wide format uses one column per unique
value of the names_from parameter, with observation dates (time) as
rows and values (value) as cell contents.
vintages_wide(df, names_from = "pub_date")
df |
A data frame or tibble containing vintages data in long format. |
names_from |
The name of the column whose unique values will be used
as column names in the wide format. Defaults to |
If an id column is present, the function returns a named list of
wide-format data frames, one for each unique id. Otherwise, it returns a
single wide-format data frame.
Other helpers:
print.tbl_vintage(),
summary.tbl_vintage(),
tbl_sum.tbl_vintage(),
tbl_vintage,
validate_vintages(),
vintages_long()
# Example wide-format data
long_data <- dplyr::filter(reviser::gdp, id == "US")
# Convert to wide format
wide_data <- vintages_wide(long_data)
# Example list of wide-format data frames
wide_list <- list(
A = wide_data$US,
B = wide_data$US
)
# Convert list to long format
long_data1 <- vintages_long(wide_data, names_to = "pub_date")
long_data2 <- vintages_long(wide_list, names_to = "pub_date")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.