View source: R/data_adapters.R
| convert_to_nweeks | R Documentation |
Resamples daily or weekly data to n-week periods. Handles week-ending calculations and various aggregation methods.
convert_to_nweeks(data, n = 1, method = "last")
data |
Data.table with Date column and price columns |
n |
Number of weeks to aggregate (default: 1 for weekly) |
method |
Aggregation method: "last" or "mean" (default: "last") |
Data.table resampled to n-week frequency
data("sample_prices_daily")
# Convert daily to weekly
weekly <- convert_to_nweeks(sample_prices_daily, n = 1)
# Convert to bi-weekly
biweekly <- convert_to_nweeks(sample_prices_daily, n = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.