Calculates the Acute:Chronic Workload Ratio (ACWR) from Strava data.
Usage
calculate_acwr(
stoken,
activity_type = NULL,
load_metric = "duration_mins",
acute_period = 7,
chronic_period = 28,
start_date = NULL,
end_date = NULL,
user_ftp = NULL,
user_max_hr = NULL,
user_resting_hr = NULL,
smoothing_period = 7
)
Arguments
- stoken
A valid Strava token from `rStrava::strava_oauth()`.
- activity_type
Optional. Filter activities by type (e.g., "Run", "Ride"). Default `NULL` includes all types.
- load_metric
Method for calculating daily load (e.g., "duration_mins", "distance_km", "tss", "hrss"). Default "duration_mins".
- acute_period
Days for the acute load window (e.g., 7).
- chronic_period
Days for the chronic load window (e.g., 28). Must be greater than `acute_period`.
- start_date
Optional. Analysis start date (YYYY-MM-DD string or Date). Defaults to one year ago.
- end_date
Optional. Analysis end date (YYYY-MM-DD string or Date). Defaults to today.
- user_ftp
Required if `load_metric = "tss"`. Your Functional Threshold Power.
- user_max_hr
Required if `load_metric = "hrss"`. Your maximum heart rate.
- user_resting_hr
Required if `load_metric = "hrss"`. Your resting heart rate.
- smoothing_period
Days for smoothing the ACWR using a rolling mean (e.g., 7). Default 7.
Value
A data frame with columns: `date`, `atl` (Acute Load), `ctl` (Chronic Load), `acwr` (raw ACWR), and `acwr_smooth` (smoothed ACWR) for the specified date range.
Details
Calculates daily load, ATL, CTL, raw ACWR, and smoothed ACWR from Strava activities.
Provides data for `plot_acwr`. Fetches extra prior data for accurate initial CTL. Fetching can be slow for long periods.
Examples
# 使用模拟数据示例 (注意: 模拟数据本身已是计算结果, 此处仅作演示)
data(Athlytics_sample_data)
if (!is.null(athlytics_sample_acwr)) {
print(head(athlytics_sample_acwr))
}
#> # A tibble: 6 × 5
#> date atl ctl acwr acwr_smooth
#> <date> <dbl> <dbl> <dbl> <dbl>
#> 1 2024-05-07 15.8 9.90 1.60 NA
#> 2 2024-05-08 15.8 9.90 1.60 NA
#> 3 2024-05-09 18.7 9.76 1.92 NA
#> 4 2024-05-10 14.0 9.76 1.44 NA
#> 5 2024-05-11 14.0 9.76 1.44 NA
#> 6 2024-05-12 11.9 9.76 1.22 NA
# \donttest{
# 使用真实数据的示例(需要认证)
stoken <- rStrava::strava_oauth(..., cache = TRUE)
#> Error: '...' used in an incorrect context
# 计算跑步的ACWR (使用运动时长)
run_acwr <- calculate_acwr(stoken = stoken, activity_type = "Run",
load_metric = "duration_mins")
#> Error: object 'stoken' not found
print(tail(run_acwr))
#> Error: object 'run_acwr' not found
# 计算骑行的ACWR (使用TSS, 需要FTP)
ride_acwr_tss <- calculate_acwr(stoken = stoken, activity_type = "Ride",
load_metric = "tss", user_ftp = 280)
#> Error: object 'stoken' not found
print(tail(ride_acwr_tss))
#> Error: object 'ride_acwr_tss' not found
# }