Skip to contents

summary.act_tbl returns a tibble with canonical information about the activity.

Usage

# S3 method for class 'act_tbl'
summary(object, full = FALSE, units = c("imperial", "metric"), ...)

Arguments

object

an object for which a summary is desired

full

Whether every column should be included, and filled with NA if missing. Most useful to ensure the tibble has the same shape for every file, allowing eventual use of dplyr::bind_rows() or purrr::map_dfr() to create a full summary data set.

units

Which units should be used?

  • "imperial" returns distance in miles, pace in minutes per mile, and elevation in feet.

  • "metric" returns distance in kilometers, pace in minutes per kilometer, and elevation in meters.

...

Additional arguments.

Value

Returns a tibble with a single row, containing a summary of the given act_tbl.

Details

This is designed to allow for easy creation of activity summary data sets by mapping summary over each act_tbl then using dplyr::bind_rows(), purrr::map_dfr(), or equivalent to create a complete data set.

Examples

example_gpx_file <- system.file(
  "extdata",
  "running_example.gpx.gz",
  package = "activatr"
)
act_tbl <- parse_gpx(example_gpx_file)
summary(act_tbl)
#> # A tibble: 1 × 9
#>   Distance Date                Time               
#>      <dbl> <dttm>              <Duration>         
#> 1     9.41 2018-11-03 14:24:45 4622s (~1.28 hours)
#> # ℹ 6 more variables: AvgPace <Duration>, MaxPace <Duration>, ElevGain <dbl>,
#> #   ElevLoss <dbl>, AvgElev <dbl>, Title <chr>

if (FALSE) { # \dontrun{
files <- list.files("path/to/many/files", pattern = "*.gpx")
gpxs <- files |> purrr::map(\(f) parse_gpx(f))
summaries <- gpxs |> purrr::map_dfr(\(g) summary(g, full = TRUE))
} # }