mutate_with_speed: Augments an 'act_tbl' with a speed column

View source: R/mutate.R

mutate_with_speedR Documentation

Augments an act_tbl with a speed column

Description

This returns a mutated act_tbl with a new column representing speed, in meters per second. See vignette("pace") for examples.

Usage

mutate_with_speed(df, method = c("2D", "3D"), lead = 0, lag = 1)

Arguments

df

An act_tbl object

method

If "2D" (default), ignores elevation. If "3D", includes elevation. "3D" is not often necessary, but for skiing activities is likely to yield a more accurate value.

lead

How far ahead to look for the "end" point.

lag

How far behind to look for the "start" point.

Details

The speed is determined by looking at the time difference between the current point and the previous point: hence, it is always NA for the first row in the data frame.

The lead and lag values are helpful to get "smoother" values, especially if the provided activity file has GPS errors in it.

Value

That same act_tbl, but with a new speed column, in meters per second.

Examples

example_gpx_file <- system.file(
  "extdata",
  "running_example.gpx.gz",
  package = "activatr"
)
example_act_tbl <- parse_gpx(example_gpx_file)
example_act_tbl_with_speed <- mutate_with_speed(example_act_tbl)
example_act_tbl_with_speed

dschafer/activatr documentation built on July 29, 2024, 3:18 a.m.