Reads the CSV or JSON produced by a mobile collection tool and returns a
data frame with parsed timestamps and a study-day index, ready for
validate_ema() and compliance().
Arguments
- path
Path to a
.csvor.jsonfile.- start_date
Date (or something
as.Date()accepts) on which the study began. Used to computestudy_daywhen the file does not already have it.- tz
Time zone to interpret timestamps in. Defaults to
"UTC", which matches the ISO 8601 output of the companion app.- timestamp_col
Name of the column holding the timestamp. Real files call it many things (
datetime,time,recorded_at); give the name here and it is renamed totimestampon the way in.
Value
A data frame with timestamp as POSIXct, study_day as integer
when derivable, and all other columns unchanged.
Details
The expected columns are timestamp plus whatever was measured. Only
timestamp is required. If start_date is supplied (or the file already
carries a study_day column) a study_day index is attached, counting from
1 on the first day of the study.
Examples
f <- system.file("extdata", "example_ema.csv", package = "nof1kit")
if (nzchar(f)) head(read_ema(f))