Generate Walk Bouts

library(walkboutr)
The walkboutr package will process GPS and accelerometry data and create two different outputs:

  1. Full dataset: This dataframe contains all of the original data (latitude, longitude, activity counts) as well as the epoch start time. This time will match the times associated with the accelerometry data, and the GPS data have been matched up to the closest accelerometry epochs. The time variable returned, thus, reflects that of the accelerometry data. Note: GPS data are assigned to an epoch start time by rounding down the time associated with the GPS datapoint to the nearest epoch start time. For example, if epochs in the accelerometry data are 30 seconds, the time associated with a GPS data point will be rounded down to the nearest 30-second increment.

  2. Summarized dataset: This dataframe does not contain any of the original GPS/accelerometry data, and is thus completely de-identified and shareable. The output contains one row for each bout (walking or otherwise) as well as information on the median speed for that bout, whether there was a complete day worth of data for the bout, the start time of the bout, the duration in minutes, and the bout category. More details on bout category can be found below.

First we will generate some sample data:

gps_data <- generate_walking_in_seattle_gps_data()
accelerometry_counts <- make_full_day_bout_without_metadata()

Now that we have sample data, we can look at how walkboutr generates bouts:

walk_bouts <- identify_walk_bouts_in_gps_and_accelerometry_data(gps_data, accelerometry_counts)
summary_walk_bouts <- summarize_walk_bouts(walk_bouts)

The bouts identified look like this:

bout bout_category activity_counts time non_wearing complete_day latitude longitude speed
1 walk_bout 500 2012-04-07 00:03:00 FALSE TRUE 47.64979 122.3757 1.1009735
1 walk_bout 500 2012-04-07 00:05:00 FALSE TRUE 47.69260 122.4185 2.7901428
1 walk_bout 500 2012-04-07 00:07:00 FALSE TRUE 47.75359 122.4795 0.9801357
1 walk_bout 500 2012-04-07 00:05:30 FALSE TRUE 47.70575 122.4317 2.7249735
1 walk_bout 500 2012-04-07 00:06:00 FALSE TRUE 47.71839 122.4443 4.0867381
1 walk_bout 500 2012-04-07 00:06:30 FALSE TRUE 47.73835 122.4643 3.0513150

We can now use the second function to generate our summarized dataset, which is de-identified and shareable:

bout median_speed complete_day bout_start duration bout_category
1 2.736466 TRUE 2012-04-07 00:02:30 5.0 walk_bout
2 2.555720 TRUE 2012-04-07 00:09:30 4304.5 walk_bout
The bout categories reflected in these outputs are defined as follows:

In order to better visualize our bouts, we can also plot the accelerometry counts and GPS radius.

accelerometry_counts <- make_smallest_bout_without_metadata()
gps_data <- generate_walking_in_seattle_gps_data()
generate_bout_plot(accelerometry_counts, gps_data, 1)