powered by
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.table resampled to n-week frequency
Data.table with Date column and price columns
Number of weeks to aggregate (default: 1 for weekly)
Aggregation method: "last" or "mean" (default: "last")
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)
Run the code above in your browser using DataLab