View source: R/spectrace_find_invalid.R
spectrace_find_invalid | R Documentation |
This function detects periods of invalid Spectrace data, that is, when the sensor was not worn (nonwear) or covered. Invalid periods are detected by finding clusters of consecutive values of low activity (nonwear) or illuminance (covered).
spectrace_find_invalid(
lightData,
flag_only = FALSE,
nonwear_min_length = "10 mins",
nonwear_max_interrupt = "2 mins",
nonwear_smooth_window = "10 mins",
covered_min_length = "10 mins",
covered_max_interrupt = "2 mins",
covered_threshold = 1
)
lightData |
Data frame containing the calibrated light data. The data needs to contain the activity column. If the data frame is grouped (see group_by), invalid periods are detected per group. It is highly recommended to group the data before passing it to this function, otherwise the data is considered as one continuous timeseries. |
flag_only |
Logical. Should only the logical flag for whether the data is invalid be returned as a column? If FALSE (default) the cluster index, and start and end index for each invalid cluster are returned as a column. |
nonwear_min_length |
String. Minimum length for consecutive low activity values to be considered as invalid. Must be in the format "[numeric] [unit]", with possible units ("seconds","minutes","hours","days"). Units can be abbreviated. |
nonwear_max_interrupt |
String. Maximum length of consecutive high activity values interrupting consecutive low activity values. Invalid periods can then contain interruptions of up to the specified length. Must be specified in the format "[numeric] [unit]", with possible units ("seconds","minutes", "hours","days"). Units can be abbreviated. |
nonwear_smooth_window |
String. Size of smoothing window for detecting low activity periods. Must be specified in the format "[numeric] [unit]", with possible units ("seconds","minutes","hours","days"). Units can be abbreviated. |
covered_min_length |
String. Minimum length for consecutive low illuminance values to be considered as invalid. Must be in the format "[numeric] [unit]", with possible units ("seconds","minutes","hours","days"). Units can be abbreviated. |
covered_max_interrupt |
String. Maximum length of consecutive high illuminance values interrupting consecutive low illuminance values. Invalid periods can then contain interruptions of up to the specified length. Must be specified in the format "[numeric] [unit]", with possible units ("seconds","minutes", "hours","days"). Units can be abbreviated. |
covered_threshold |
Numeric. Threshold illuminance to consider sensor as covered. Defaults to 1 lux. |
If the data frame is grouped (see group_by), invalid periods are detected per group. It is highly recommended to group the data before passing it to this function, otherwise the data is considered as one continuous timeseries.
Original data frame with additional columns indicating whether a sample is covered or nonwear and if 'flag_only = FALSE' indicating the cluster indices, and indices of start and end of each invalid cluster.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.