Learn R Programming

walkboutr

The goal of walkboutr is to process GPS and accelerometry data into walking bouts. walkboutr will either return the original dataset along with bout labels and categories, or a summarized and de-identified dataset that can be shared for collaboration.

Installation

You can install the development version of walkboutr from GitHub with:

# install.packages("devtools")
devtools::install_github("rwalkbout/walkboutr")

Basic Usage

Simulated sample data

This is an example of simulated data that could be processed by walkboutr. The GPS data contain the required columns: time, latitude, longitude, speed. The accelerometry data contain the required columns: time, accerometry counts. These data have no extra columns, do not contain NAs, and don’t contain negative speeds or accelerometry counts. All times are also in date-time format.

library(walkboutr)
# generate sample gps data:
gps_data <- generate_walking_in_seattle_gps_data() 
# generate sample accelerometry data:
accelerometry_counts <- make_full_day_bout_without_metadata() 

GPS data:

Now that we have sample data, we can look at how the walkboutr package works. There are two top level functions that will allow us to generate either (1) a dataset with bouts and bout categories with all of our original data included, or (2) a summary dataset that is completely de-identified and shareable for research purposes.

Walk bout dataset including original data

walk_bouts <- identify_walk_bouts_in_gps_and_accelerometry_data(gps_data,accelerometry_counts)

Summarized walk bout dataset

This dataset is a set of labelled bouts that are categorized (bout_category) and contains information on bout specific median speed (median_speed), the start time of the bout (bout_start), the duration of the bout (in minutes for computational ease, duration), and a flag for whether the bout came from a dataset with a complete day worth of data (complete_day).

summary <- summarize_walk_bouts(walk_bouts)

In this example, we have 2 bout(s), and each bout has a label. Bout 1 occurred on 2012.04.07 and has a complete day worth of data (complete_day = TRUE) and a start time of 00:02:30. This bout lasted 5 minutes, or 0.0833333 hours. The bout is a non-walk bout because the participant was moving too slowly for this walk to be considered walking.

For more information on bout categories and how these are assigned, please see the vignette titled Generate Walk Bouts.

Copy Link

Version

Install

install.packages('walkboutr')

Monthly Downloads

142

Version

0.6.0

License

BSD_3_clause + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Lauren Blair Wilner

Last Published

January 30th, 2024

Functions in walkboutr (0.6.0)

generate_walking_in_seattle_gps_data

Generate GPS data for a walking activity in Seattle, WA
identify_bouts

Identify Bouts:
generate_bout_category

Generate bout categories
identify_complete_days

Identify complete wearing days This function identifies complete days based on accelerometry data by calculating the total number of epochs worn per day and comparing it to the minimum number of wearing epochs per day required to consider a day complete.
make_inactive_period

Create an inactive period
make_smallest_bout

Make the smallest bout dataset
add_date_and_format

Add date and format to activity counts
make_smallest_bout_window

Create the smallest bout window
process_bouts_and_gps_epochs_into_walkbouts

Process bouts and GPS epochs into walk bouts
generate_bout_plot

Generate Bout Plot
make_non_bout_window

Create a non-bout window
collate_arguments

Collate Arguments This function collates user-provided arguments with pre-defined parameters and constants.
process_gps_data_into_gps_epochs

Convert GPS data into GPS epochs
assign_epoch_start_time

Assign Epoch Start Time
generate_bout_radius

Generate Bounding Circle Radius for Walking Bouts
constants

List of Constants non_wearing_min_threshold_epochs Number of consecutive epochs with activity counts of 0 that constitute a non_wearing period. min_wearing_hours_per_day Minimum number of hours in a day an individual must wear an accelerometer for the day to be considered complete. min_gps_obs_within_bout Minimum number of GPS observations within a bout for that bout to be considered to have complete GPS data. min_gps_coverage_ratio Minimum ratio of data points with versus without GPS data for the bout to be considered to have complete GPS data. dwellbout_radii_quantile Threshold for outliering GPS data points - any data points above the 95th percentile are outliered. max_dwellbout_radii_ft Maximum radius, in feet, of a bounding circle that would be considered a dwell bout (rather than a potential walk bout). min_dwellbout_obs Minimum number of observations to consider something a potential dwell bout. max_walking_cpe Maxiumum CPE value before the accelerometer is considered to be picking up on an activity other than walking. min_walking_speed_km_h Minimum speed considered walking. max_walking_speed_km_h Maximum speed considered walking.
make_full_day_bout_without_metadata

Create activity counts for a full day bout without metadata
make_active_period

Generate accelerometry datasets
make_full_walk_bout_df

Create a data frame of walking bouts with GPS data
make_smallest_bout_with_largest_inactive_period

Generate a sequence of accelerometer counts representing the smallest bout with the largest inactive period
make_smallest_bout_with_smallest_non_wearing_period

Generate the smallest bout with the smallest non-wearing period dataset
validate_accelerometry_data

Validate accelerometry input data
outlier_gps_points

Outlier GPS data points This function identifies outlier GPS points for the bout radius calculation from a given set of latitude and longitude coordinates.
validate_gps_data

Validate GPS data
parameters

Global parameters and constants
walkboutr-package

walkboutr: Generate Walk Bouts from GPS and Accelerometry Data
make_full_day_bout

Create activity counts for a full day bout
make_smallest_bout_without_metadata

Create the smallest bout window without metadata
identify_walk_bouts_in_gps_and_accelerometry_data

Identify walking bouts in GPS and accelerometry data:
identify_non_wearing_periods

Identify non-wearing periods: This function identifies non-wearing periods in accelerometry data based on a threshold of consecutive epochs with activity counts of 0.
make_smallest_complete_day_activity

Generate an activity sequence for a complete day with minimal activity
summarize_walk_bouts

Summarize walking bouts: This function summarizes walking bouts and calculates the median speed, complete day, non-wearing, bout start, and duration of each bout.
run_length_encode

Run Length Encoding:
make_smallest_nonwearing_window

Create smallest non-wearing window
next_lat_long

Calculate next latitude and longitude based on current location, speed, direction, and time elapsed.
%>%

Pipe operator
process_accelerometry_counts_into_bouts

Process Accelerometry Counts into Bouts
generate_gps_data

Generate a dataset with date-time, speed, and latitude and longitude of someone moving through space on a walk in Seattle
evaluate_gps_completeness

Evaluate GPS completeness for each walking bout