Skip to contents

Visualizes the Acute:Chronic Workload Ratio (ACWR) trend over time.

Usage

plot_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,
  highlight_zones = TRUE,
  acwr_df = NULL
)

Arguments

stoken

A valid Strava token from `rStrava::strava_oauth()`. Required unless `acwr_df` is provided.

activity_type

Type(s) of activities to analyze (e.g., "Run", "Ride").

load_metric

Method for calculating daily load (e.g., "duration_mins", "distance_km", "tss", "hrss").

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 ~1 year ago.

end_date

Optional. Analysis end date (YYYY-MM-DD string or Date). Defaults to today.

smoothing_period

Days for smoothing the ACWR using a rolling mean (e.g., 7). Default 7.

acwr_df

Optional. A pre-calculated data frame from `calculate_acwr`. If provided, `stoken` and other calculation parameters are ignored.

Value

A ggplot object showing the ACWR trend.

Details

Plots the ACWR trend over time. Uses pre-calculated data or calls `calculate_acwr` (can be slow). ACWR is calculated as acute load / chronic load. A ratio of 0.8-1.3 is often considered the "sweet spot". If `acwr_df` is not provided, calls `calculate_acwr` first (can be slow and hit API limits).

Examples

# 使用模拟数据示例
data(Athlytics_sample_data)
if (!is.null(athlytics_sample_acwr)) {
  p <- plot_acwr(acwr_df = athlytics_sample_acwr)
  print(p)
}
#> Generating plot...


# \donttest{
# 使用真实数据的示例(需要认证)
stoken <- rStrava::strava_oauth(..., cache = TRUE)
#> Error: '...' used in an incorrect context

# 绘制跑步的ACWR趋势(使用运动时长作为负荷指标)
plot_acwr(stoken = stoken,
          activity_type = "Run",
          load_metric = "duration_mins",
          acute_period = 7,
          chronic_period = 28)
#> Error: object 'stoken' not found

# 绘制骑行的ACWR趋势(使用TSS作为负荷指标)
plot_acwr(stoken = stoken,
          activity_type = "Ride",
          load_metric = "tss",
          user_ftp = 280)  # 需要提供FTP值
#> Error: object 'stoken' not found
# }