add_block_labels: add_block_labels

Description Usage Arguments Details Examples

View source: R/SL_tbl_trans.R

Description

Classify observations from an SL_tibble into block labels using available date-time information. See more information about "blocks" under the details section. Daylight savings is ignored, and started on 31st March 2013.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
add_block_labels(
  tab,
  type = c("hour_in_day", "epoch", "day", "week", "weekday", "month", "date"),
  interval = "start",
  warning = TRUE,
  start_date = getOption("SL_start"),
  epoch_levels = getOption("SL_epoch_levels"),
  epoch_ubs = getOption("SL_epoch_ubs"),
  unsafe = F
)

Arguments

tab

An SL_tibble as returned by the function load_SL_tibble.

type

A character vector of block label types to include. Can be one or more of "epoch", "day", "week", "weekday", "month" and "date". Any block label types that are not inferrable from the available date-time data are ignored.

interval

A character string that decides how block membership is decided when tab is of class interval_SL_tibble. Can be either "start" (use start_timestamp), "end" (use end_timestamp) or "middle" (use the midpoint between start_timestamp and end_timestamp).

warning

Logical. If TRUE then a warning is produced whenever a block label type is not inferrable from the available date-time data.

start_date

Date. The date that the StudentLife study started.

epoch_levels

A character vector of epoch levels.

epoch_ubs

An integer vector that defines the hour that is the upper boundary of each epoch.

unsafe

A logical. Default is FALSE. If this is set to TRUE then less checks will be performed.

Details

Block label types can be one or more of "epoch" (giving labels morning, evening, afternoon and night), "day" (giving number of days since the start_date of the StudentLife study), "week" (giving integer number of weeks since the first week of the StudentLife study, rounded downs), "weekday" (giving the day of the week), "month" (giving integer number of months since the start of the StudentLife study, rounded down) and "date".

Examples

1
2
3
4
5
6
7
8
d <- tempdir()
download_studentlife(location = d, url = "testdata")

tab <- load_SL_tibble(
  loc = d, schema = "sensing", table = "activity", csv_nrows = 10)

b_tab <- add_block_labels(tab)
b_tab

studentlife documentation built on Nov. 1, 2020, 9:07 a.m.