Learn R Programming

CircaCP (version 0.1.2)

screen_wear: Screen wear and extract the longest valid minute-level segment

Description

Determines the native epoch from the first two time stamps, decimates to 1-minute resolution (if needed), checks total minutes \(\ge\) 1440*min_days, and within that finds the longest contiguous segment where runs of consecutive zeros do not exceed max_zero_run minutes.

Usage

screen_wear(
  df,
  min_days = 5L,
  max_zero_run = 120L,
  date_col = "Date",
  time_col = "Time",
  activity_col = "Activity"
)

Value

A list with elements:

status

"ok" if a qualifying segment is found, otherwise a message.

epoch_inferred

Detected original epoch in seconds (15, 30, 60).

out_idx

Indices of the kept segment in the input.

clean_df

Minute-level data.frame of the selected segment (if ok).

Arguments

df

data.frame with columns Date, Time, Activity in time order.

min_days

Integer minimum number of whole days required (default 5).

max_zero_run

Integer maximum allowed length (minutes) of a run of zeros.

date_col

Name of the date column.

time_col

Name of the time column.

activity_col

Name of the activity column used to determine wear/non-wear.

Details

Decimation rule: 15 s \(\rightarrow\) factor 4; 30 s \(\rightarrow\) factor 2; 60 s \(\rightarrow\) factor 1. The zero-run criterion is applied on the 1-minute Activity series.

See Also

import_acti_file(), sleep_cos(), sleep_detection()