data-raw/ACT24/sample_code/sample_code.R

# THIS FILE CONTAINS SAMPLE CODE FOR PROCESSING A SINGLE PARTICIPANT'S ACT24
# DATA, HAVING THE FORMAT SHOWN IN `SAMPLE_FILE.CSV`

## Setup ####

  rm(list = ls()) # Clear memory
  library(magrittr) # Attach magrittr package (makes code more readable)
  devtools::load_all() # Load functions etc. from FLASH package

## Run the code ####

  path_to_file <- "data-raw/ACT24/sample_code/sample_file.csv"

  events <-
    data.table::fread(path_to_file, stringsAsFactors = FALSE) %>%
    data.frame(stringsAsFactors = FALSE)

  minutes <-
    events %>%
    act24_wrapper(.$UserName[1], ., TRUE)

## Optional -- view the data ####

  head(events)
  head(minutes)

  View(events)
  View(minutes)

## Optional -- save the data ####

  saveRDS(
    events,
    "data-raw/ACT24/sample_code/sample_output_events.rds"
  )

  saveRDS(
    minutes,
    "data-raw/ACT24/sample_code/sample_output_60s.rds"
  )

  ## Read back in
  #
  # events <- readRDS(
  #   "data-raw/ACT24/sample_code/sample_output_events.rds"
  # )
  # minutes <- readRDS(
  #   "data-raw/ACT24/sample_code/sample_output_60s.rds"
  # )
PAHPLabResearch/FLASH documentation built on May 15, 2020, 7:08 p.m.