Visualizes the trend of Efficiency Factor (EF) over time.
Arguments
- stoken
A valid Strava token from `rStrava::strava_oauth()`. Required unless `ef_df` is provided.
- activity_type
Type(s) of activities to analyze (e.g., "Run", "Ride").
- ef_metric
Metric to calculate: "Pace_HR" (Speed/HR) or "Power_HR" (Power/HR).
- 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.
- min_duration_mins
Minimum activity duration (minutes) to include. Default 20.
- add_trend_line
Add a smoothed trend line (`geom_smooth`)? Default `TRUE`.
- smoothing_method
Smoothing method for trend line (e.g., "loess", "lm"). Default "loess".
- ef_df
Optional. A pre-calculated data frame from `calculate_ef`. If provided, `stoken` and other calculation parameters are ignored.
Details
Plots the Efficiency Factor (EF) trend over time. Uses pre-calculated data or calls `calculate_ef`.
Plots EF (output/HR based on activity averages). An upward trend often indicates improved aerobic fitness. Points colored by activity type. If `ef_df` is not provided, calls `calculate_ef` first.
Examples
# 使用模拟数据示例
data(Athlytics_sample_data)
if (!is.null(athlytics_sample_ef)) {
p <- plot_ef(ef_df = athlytics_sample_ef)
print(p)
}
#> Generating plot...
#> `geom_smooth()` using formula = 'y ~ x'
# \donttest{
# 使用真实数据的示例(需要认证)
stoken <- rStrava::strava_oauth(..., cache = TRUE)
#> Error: '...' used in an incorrect context
# 绘制跑步的Pace/HR EF趋势 (最近6个月)
plot_ef(stoken = stoken,
activity_type = "Run",
ef_metric = "Pace_HR",
start_date = Sys.Date() - months(6))
#> Error: object 'stoken' not found
# 绘制骑行的Power/HR EF趋势
plot_ef(stoken = stoken,
activity_type = "Ride",
ef_metric = "Power_HR")
#> Error: object 'stoken' not found
# 绘制多种跑步类型的Pace/HR EF趋势 (无趋势线)
plot_ef(stoken = stoken,
activity_type = c("Run", "VirtualRun"),
ef_metric = "Pace_HR",
add_trend_line = FALSE)
#> Error: object 'stoken' not found
# }