Type: | Package |
Title: | Collect and Process Physical Activity Direct Observation Data |
Version: | 0.3.0 |
Depends: | R (≥ 2.10) |
Description: | Two-part system for first collecting then managing direct observation data, as described by Hibbing PR, Ellingson LD, Dixon PM, & Welk GJ (2018) <doi:10.1249/MSS.0000000000001486>. |
License: | GPL-3 | file LICENSE |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | svDialogs (≥ 1.0.0), stats |
RoxygenNote: | 7.1.2 |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
URL: | https://github.com/paulhibbing/Observation |
BugReports: | https://github.com/paulhibbing/Observation/issues |
NeedsCompilation: | no |
Packaged: | 2022-09-05 04:36:08 UTC; prhibbing |
Author: | Paul R. Hibbing [aut, cre] |
Maintainer: | Paul R. Hibbing <paulhibbing@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2022-09-05 08:30:11 UTC |
Collect and Process Physical Activity Direct Observation Data
Description
This provides a free and easy way to document and annotate physical activity behaviors using direct observation.
Core functions
Associated References
Hibbing PR, Ellingson LD, Dixon PM, & Welk GJ (2018). Adapted Sojourn Models to Estimate Activity Intensity in Youth: A Suite of Tools. Medicine and Science in Sports and Exercise. 50(4), 846-854. doi:10.1249/MSS.0000000000001486.
Note
'Observation' functions accept further arguments that are passed to functions from the 'svDialogs' package. Doing so may improve your experience using the 'Observation' package. See the package vignette for more information.
Examples
# Example of non-interactive use
data(example_data)
compendium_reference(example_data, FALSE, kids = "yes", mvpa = "yes")
# Example of interactive use
if (interactive()) {
observation_data <- data_collection_program()
full_data <- compendium_reference(observation_data)
}
Verify Correctness of User-Specified Interactive Preference
Description
Verify Correctness of User-Specified Interactive Preference
Usage
check_interactive(interactive)
Arguments
interactive |
Logical. Should program be run interactively? |
Consult the Compendium of Physical Activities to Encode Direct Observation Intensities
Description
Consult the Compendium of Physical Activities to Encode Direct Observation Intensities
Usage
compendium_reference(obs_data, interactive = TRUE, ...)
Arguments
obs_data |
A data frame outputted from
|
interactive |
Logical. Should program be run interactively? |
... |
Additional arguments passed to method-like functions (under "See Also" below) |
Value
A data frame fully annotated with intensity values
Note
If 'interactive = TRUE', but R is not being used interactively, a message is issued and an override is implemented to set 'interactive = FALSE'.
See Also
Other processing functions:
interactive_compendium_reference()
,
manual_compendium_reference()
Examples
data(example_data)
compendium_reference(example_data, FALSE, kids = "yes", mvpa = "yes")
if (interactive()) {
compendium_reference(example_data)
}
Collect Direct Observation Data
Description
A generic-like function for collecting direct observation data manually or interactively, depending on user-specified preference and session capabilities.
Usage
data_collection_program(interactive = TRUE, ...)
Arguments
interactive |
Logical. Should program be run interactively? |
... |
Additional arguments passed to method-like functions (under "See Also" below) |
Note
If 'interactive = TRUE', but R is not being used interactively, a message is issued and an override is implemented to set 'interactive = FALSE'.
See Also
Other collection functions:
interactive_data_collection_program()
,
manual_data_collection_program()
Examples
if (interactive()) {
data_collection_program()
}
# Load Sample of interactively-collected data for comparison
# with manually-entered data
data("example_data")
# Example of manually defining input variables -------------------------
id <- "Test_ID"
timestamps <- c("2018-05-06 02:40:37", "2018-05-06 02:40:46",
"2018-05-06 02:40:59", "2018-05-06 02:41:14",
"2018-05-06 02:41:27", "2018-05-06 02:41:37",
"2018-05-06 02:41:48", "2018-05-06 02:42:03",
"2018-05-06 02:42:24", "2018-05-06 02:42:39",
"2018-05-06 02:42:53")
activities <- c("sitting still", "sitting stretching",
"sitting shoulder press", "sitting cycling",
"standing still", "standing stretching",
"standing shoulder press", "walking slowly",
"walking quickly", "jumping jacks")
durations <- c(9, 13, 15, 13, 10, 11, 15, 21, 15, 14.460825920105)
Tree_Intensity <- c("Sedentary", "Sedentary/Light",
"Light/Moderate", "Indeterminate", "Light", "Light",
"Light/Moderate", "Light", "MVPA", "Light/Moderate")
seated <- c("yes", "yes", "yes", "yes", "no", "no", "no",
"no", "no", "no")
large_muscles_moving <- c("no", "yes", "yes", "yes",
"no", "yes", "yes", "yes", "yes", "yes")
slow <- c(NA, "yes", "yes", "no", NA, "yes", "yes",
"no", "no", "no")
slowed_by_resistance <- c(NA, "no", "yes", NA, NA,
"no", "yes", NA, NA, NA)
ambulation <- c(NA, NA, NA, NA, NA, NA, NA,
"yes", "yes", "no")
light_walking <- c(NA, NA, NA, NA, NA, NA,
NA, "yes", "no", NA)
# Example of using the manual program ----------------------------------
manual_data <- data_collection_program(
interactive = FALSE, id = id, timestamps = timestamps,
activities = activities, durations = durations, seated = seated,
large_muscles_moving = large_muscles_moving, slow = slow,
slowed_by_resistance = slowed_by_resistance, ambulation = ambulation,
light_walking = light_walking
)
# Comparing output of interactive vs manual program --------------------
test_names <- intersect(names(example_data), names(manual_data))
test_names <- setdiff(names(test_names), "duration_s")
all.equal(
example_data[ ,test_names],
manual_data[ ,test_names],
scale = 1,
tolerance = 5
)
Sample data collected interactively with direct observation program.
Description
A data set assembled by running the interactive direct observation program and entering a variety of activities.
Usage
example_data
Format
A data frame with 10 rows and 15 variables:
- id
The user-inputted identification code for the trial
- User_Timestamp
The user-inputted start time for the activity
- Auto_Timestamp
The automatic timestamp generated by button click, retained as a backup if an error occurs in User_Timestamp
- dayofyear
The numeric day of the year (i.e., julian date)
- minofday
The numeric minute of the day (e.g. 0 for midnight and 1439 for 23:59)
- Activity
The user-inputted activity description
- duration_s
The duration of the activity (in seconds), based on User_Timestamp
- auto_duration_s
The duration of the activity (in seconds), based on Auto_Timestamp
- Tree_Intensity
The pre-classified activity intensity, based on user input to the program's decision tree
- seated
User-inputted response to the seated prompt
- large_muscles_moving
User-inputted response to the large-muscles-moving prompt
- slow
User-inputted response to the slow prompt
- slowed_by_resistance
User-inputted response to the slowed-by-resistance prompt
- ambulation
User-inputted response to the ambulation prompt
- light_walking
User-inputted response to the light-walking prompt
Helper Function for Interactive Intensity Coding Process.
Description
Interface for looking up Compendium values to assign an intensity to an activity.
Usage
interactive_comp_lookup(incorrect_entries, Levels, compendium, ...)
Arguments
incorrect_entries |
A vector of activities that have not been correctly coded yet |
Levels |
A vector of intensity levels from which to select |
compendium |
A compendium version, passed from
|
... |
Arguments passed to dialog functions |
Interactively Consult the Compendium of Physical Activities to Encode Direct Observation Intensities
Description
Interactively Consult the Compendium of Physical Activities to Encode Direct Observation Intensities
Usage
interactive_compendium_reference(obs_data, ...)
Arguments
obs_data |
A data frame outputted from
|
... |
Arguments passed to dialog functions |
Value
A data frame fully annotated with intensity values
Note
interactive_compendium_reference
is called
within compendium_reference
when
interactive = TRUE
and the session is interactive.
See Also
Other processing functions:
compendium_reference()
,
manual_compendium_reference()
Examples
if (interactive()) {
data(example_data)
compendium_reference(example_data)
observation_data <- data_collection_program()
compendium_reference(observation_data)
}
Interactively Collect Direct Observation Data
Description
Interactively Collect Direct Observation Data
Usage
interactive_data_collection_program(...)
Arguments
... |
Arguments passed to dialog functions |
Value
A data frame of observation data
Note
interactive_data_collection_program
is
called within data_collection_program
when
interactive = TRUE
and the session is interactive.
This program relies heavily on dialog boxes generated by the 'svDialogs' package. Default measures are in place to ensure baseline functionality across operating systems and R interfaces. However, a better experience may be achievable by passing additional arguments to the dialog functions via '...', as the vignette for 'Observation' describes.
See Also
[example_data]
Other collection functions:
data_collection_program()
,
manual_data_collection_program()
Examples
if (interactive()) {
data_collection_program()
}
Interactively Pre-Classify Activity Intensity
Description
Interactively implement the pre-classification decision tree described at the end of Supplemental Document 3 from Hibbing et al. (2018, *Med Sci Sports Exerc*).
Usage
interactive_tree_intensity(...)
Arguments
... |
Arguments passed to dialog functions |
Manually Encode Direct Observation Intensities by Cross-Referencing the Compendium of Physical Activities
Description
Manually Encode Direct Observation Intensities by Cross-Referencing the Compendium of Physical Activities
Usage
manual_compendium_reference(
obs_data,
kids = c("yes", "no"),
mvpa = c("yes", "no")
)
Arguments
obs_data |
A data frame outputted from
|
kids |
A character scalar in |
mvpa |
A character scalar in |
Value
A list with three elements. The first (data
) is the
original data, where a Final_Intensity
column has been
populated to the extent possible, with "Indeterminate" listed for
the other activities. The second element (indeterminate
) is
another list, which has one element for each activity in
data
with Final_Intensity = "Indeterminate"
. The
elements of indeterminate
are named after the activity they
represent, and the contents are a subset of the Compendium giving
suggested matches for the activity, based on its description in
data
. The third element (compendium
) gives the entire
compendium, which can be manually cross-referenced for cases where
the suggested matches in indeterminate
do not give a suitable
match.
See Also
Other processing functions:
compendium_reference()
,
interactive_compendium_reference()
Examples
data(example_data)
example_data_processed <- compendium_reference(example_data, FALSE,
kids = "yes", mvpa = "yes")
if (interactive()) {
View(example_data_processed$data)
View(example_data_processed$indeterminate[[1]])
View(example_data_processed$compendium)
}
Manually Collect Direct Observation Data
Description
Manually Collect Direct Observation Data
Usage
manual_data_collection_program(
id,
timestamps,
activities,
durations = NULL,
seated = NA,
large_muscles_moving = NA,
slow = NA,
slowed_by_resistance = NA,
ambulation = NA,
light_walking = NA
)
Arguments
id |
Character scalar giving ID to assign to the trial |
timestamps |
Vector of times (character or POSIX) corresponding to onset of each activity and (if |
activities |
Character vector of activities in the sequence they were performed |
durations |
Optional numeric vector giving duration of each activity, in seconds |
seated |
Character vector giving yes/no/NA response for whether the participant was seated during each activity |
large_muscles_moving |
Character vector giving yes/no/NA response for whether the participant was moving large muscles during each activity |
slow |
Character vector giving yes/no/NA response for whether muscle contractions were slow during each activity |
slowed_by_resistance |
Character vector giving yes/no/NA response for whether slow muscle contractions were slowed because of resistance |
ambulation |
Character vector giving yes/no/NA response for whether the each activity is ambulatory |
light_walking |
Character vector giving yes/no/NA response for whether ambulation was slow enough to be considered light activity instead of moderate or vigorous |
Value
A dataframe of pre-processed direct observation data generated from minimal input
Note
By default, activity duration is automatically calculated, which is accomplished via diff.POSIXt
and thus requires n + 1
timestamps, where n
is the number of activities. Alternatively, durations can be manually specified via the durations
parameter, in which case only n
timestamps are needed, corresponding to the onset of each activity.
See Also
Other collection functions:
data_collection_program()
,
interactive_data_collection_program()
Manually Pre-Classify Activity Intensity
Description
Manually implement the pre-classification decision tree described at the end of Supplemental Document 3 from Hibbing et al. (2018, *Med Sci Sports Exerc*).
Usage
manual_tree_intensity(prompt_responses)
Arguments
prompt_responses |
A vector of responses to the decision tree prompts |
Note
The vector of responses must match the structure indicated in the example, i.e., a named vector answering prompts in the following order: participant seated; large muscles contracting; slow contractions; contractions slowed by resistance; activity is ambulatory; ambulation is slow enough to be considered light activity rather than moderate or vigorous.
Examples
prompt_responses <- structure(c("yes", "no", NA, NA, NA, NA),
.Dim = c(6L, 1L), .Dimnames = list(c("seated",
"large_muscles_moving", "slow", "slowed_by_resistance",
"ambulation", "light_walking"),
"1"))
Observation:::manual_tree_intensity(prompt_responses)