Skip to contents

This function wraps the dataCollapser and the wearingMarking functions from the PhysicalActivity package. After collapsing data, the function adds time and date columns. Then, the function analyzes the dataset for nonwear time detection. Finally, the function adds two variables to the dataset: the variable non_wearing_count that contains the number 1 when the device was not worn (otherwise, 0 is used), and the variable wearing_count that contains the number 1 when the device was worn (otherwise, 0 is used).

Usage

mark_wear_time(
  dataset,
  TS = "TimeStamp",
  to_epoch = 60,
  cts = "vm",
  frame = 90,
  allowanceFrame = 2,
  streamFrame = 30
)

Arguments

dataset

A dataframe obtained using the prepare_dataset function.

TS

A character value indicating the name of the variable where date and time information are provided.

to_epoch

A numeric value indicating the length of the epoch to use (in seconds) for accumulating data. The value must be superior or equal to the recording epoch that was used for the measurement.

cts

A character value indicating the name of the variable used by the nonwear/wear detection algorithm.

frame

A numeric value for the length of the time window (in minutes) used to detect nonwear/wear time.

allowanceFrame

A numeric value for the length of the time window (in minutes) with nonzero counts allowed within the detected nonwear period.

streamFrame

A numeric value for the length of the time window required around the detected activity to validate nonwear time.

Value

A dataframe.

Examples

file <- system.file("extdata", "acc.agd", package = "activAnalyzer")
mydata <- prepare_dataset(data = file)
mydata_with_wear_marks <- mark_wear_time(
    dataset = mydata, 
    TS = "TimeStamp", 
    to_epoch = 60,
    cts  = "vm",
    frame = 90, 
    allowanceFrame = 2, 
    streamFrame = 30
    )
#> frame is 90
#> streamFrame is 30
#> allowanceFrame is 2
head(mydata_with_wear_marks)
#>             timestamp       date     time axis1 axis2 axis3 steps lux
#> 1 2021-04-07 06:00:00 2021-04-07 06:00:00     0     0     0     0   0
#> 2 2021-04-07 06:01:00 2021-04-07 06:01:00     0     0     0     0   0
#> 3 2021-04-07 06:02:00 2021-04-07 06:02:00     0     0     0     0   0
#> 4 2021-04-07 06:03:00 2021-04-07 06:03:00     0     0     0     0   0
#> 5 2021-04-07 06:04:00 2021-04-07 06:04:00     0     0     0     0   0
#> 6 2021-04-07 06:05:00 2021-04-07 06:05:00     0     0     0     0   0
#>   inclineoff inclinestanding inclinesitting inclinelying vm wearing   weekday
#> 1         60               0              0            0  0      nw Wednesday
#> 2         60               0              0            0  0      nw Wednesday
#> 3         60               0              0            0  0      nw Wednesday
#> 4         60               0              0            0  0      nw Wednesday
#> 5         60               0              0            0  0      nw Wednesday
#> 6         60               0              0            0  0      nw Wednesday
#>   days non_wearing_count wearing_count
#> 1    1                 1             0
#> 2    1                 1             0
#> 3    1                 1             0
#> 4    1                 1             0
#> 5    1                 1             0
#> 6    1                 1             0