| Title: | Rabbitly Process Data From Triaxial Accelerometers |
|---|---|
| Description: | Rabbitly Process Data From Triaxial Accelerometers. |
| Authors: | Courntey Adams [aut, cre] (ORCID: <https://orcid.org/0009-0007-3757-7507>), Jack Bilby [aut, ctb], Daniel Falster [aut, ctb] (ORCID: <https://orcid.org/0000-0002-9814-092X>), Will Cornwell [aut, ctb] (ORCID: <https://orcid.org/0000-0003-4080-4073>) |
| Maintainer: | Courntey Adams <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-11-13 01:19:36 UTC |
| Source: | https://github.com/traitecoevo/rabbit |
Compare elapsed runtime for fast (RcppRoll) and base (pure R) methods for
both roll_sum() and extract_movement_dynamics().
benchmark_movement_dynamics(df, window_size = 50, iterations = 3)benchmark_movement_dynamics(df, window_size = 50, iterations = 3)
df |
A data frame containing columns |
window_size |
An integer specifying the size of the rolling window. |
iterations |
Number of repeated timings per task/method. |
A tibble with columns task, method, iteration, and elapsed_sec.
Crop data to specified start and end times, to remove records at the beginning and end of each file. This is useful for removing records collected before the device was attached or after it was removed. crop_diurnal defaults to cropping dataframe to the first instance of 01:00:00 and the last instance of 01:00:00. crop_nocturnal defaults to cropping dataframe to the first instance of 12:00:00 and the last instance of 12:00:00. crop_ends is a more general function that allows users to specify any start and end times. crop_diurnal
crop_ends(df, start_time = "00:00:00", end_time = "24:00:00") crop_ends_diurnal(df, start_time = "01:00:00", end_time = "01:00:00") crop_ends_nocturnal(df, start_time = "12:00:00", end_time = "12:00:00")crop_ends(df, start_time = "00:00:00", end_time = "24:00:00") crop_ends_diurnal(df, start_time = "01:00:00", end_time = "01:00:00") crop_ends_nocturnal(df, start_time = "12:00:00", end_time = "12:00:00")
df |
A dataframe containing the data. |
start_time |
The desired start time |
end_time |
The desired end time |
This function takes standardised accelerometer data and caluclates a set of metrics of movement dynamics across a sliding window of specified number of datapoints. Caluclate metrics include including means, variances, covariances, of xyz, as well as overall dynamic body acceleration (ODBA) and vectorial dynamic body acceleration (VDBA). The function is designed to be fast, using the RcppRoll package to calculate rolling means and sums in C++.
extract_movement_dynamics(df, window_size = 50, method = c("fast", "base"))extract_movement_dynamics(df, window_size = 50, method = c("fast", "base"))
df |
A data frame containing the data. |
window_size |
An integer specifying the size of the rolling window. |
method |
A string specifying the method to use for rolling calculations. Options are "fast" (using RcppRoll) or "base" (using pure R implementations). The default is "fast". |
A data frame with movement dynamics metrics calculated across the sliding window.
#' @examples file_in = system.file("extdata", "raw_Pic2Jan_50000.parquet", package = "rabbit") df <- standardize_data(file_in = file_in, vars = c("Timestamp", "accX", "accY", "accZ")) |> extract_movement_dynamics()#' @examples file_in = system.file("extdata", "raw_Pic2Jan_50000.parquet", package = "rabbit") df <- standardize_data(file_in = file_in, vars = c("Timestamp", "accX", "accY", "accZ")) |> extract_movement_dynamics()
Creates synthetic triaxial accelerometer data with 1-second timestamps.
The accZ axis is centered around 1 (gravity-like baseline), while accX and accY
are centered around 0.
generate_fake_data(n)generate_fake_data(n)
n |
Integer. Number of rows to generate. |
A data frame with columns:
Character timestamp in format "%d/%m/%Y %H:%M:%S" (UTC).
Simulated x-axis acceleration values.
Simulated y-axis acceleration values.
Simulated z-axis acceleration values.
df <- generate_fake_data(1000) head(df)df <- generate_fake_data(1000) head(df)
This function accepts either a dataframe or filename (*.csv or *.parquet), checks that the time and x,y,z columns can be properly processed, auto-detects common timestamp formats, and prints out summary statistics about the data.
standardise_data( df, file_in = NULL, vars = c("Timestamp", "X", "Y", "Z"), time_function = lubridate::dmy_hms, timezone = "Australia/Adelaide", ... ) standardize_data( df, file_in = NULL, vars = c("Timestamp", "X", "Y", "Z"), time_function = lubridate::dmy_hms, timezone = "Australia/Adelaide", ... )standardise_data( df, file_in = NULL, vars = c("Timestamp", "X", "Y", "Z"), time_function = lubridate::dmy_hms, timezone = "Australia/Adelaide", ... ) standardize_data( df, file_in = NULL, vars = c("Timestamp", "X", "Y", "Z"), time_function = lubridate::dmy_hms, timezone = "Australia/Adelaide", ... )
df |
A data frame containing the data |
file_in |
A string representing the path to the input file (CSV or parquet). |
vars |
A character vector of length 4 specifying the names of the columns in df that contain the variables |
time_function |
A function to convert the time column to POSIXct. The default is lubridate::dmy_hms, which parses date-times with year, month, and day, hour, minute, and second components. |
timezone |
Timezone of where accelerometer was used |
... |
Other arguments to pass into read in function |
A data frame containing the standardised data, with the time column converted to POSIXct type.
file_in = system.file("extdata", "raw_Pic2Jan_50000.parquet", package = "rabbit") df <- standardise_data(file_in = file_in, vars = c("Timestamp", "accX", "accY", "accZ"))file_in = system.file("extdata", "raw_Pic2Jan_50000.parquet", package = "rabbit") df <- standardise_data(file_in = file_in, vars = c("Timestamp", "accX", "accY", "accZ"))