As I mentioned there are some issues with merging the sample and message data.
I am not going to make you download the SR API. I am attaching two ds, one with the samples and one with messages I am trying to merge. A lot of this is contained in the parse_edf function.
library(data.table)
remotes::install.github("dmirman/gazer")
library((gazer)
# I put the files on the git(not best practice) but will remove them after
samp <- system.file("extdata", "TJ_samp.xls", package = "gazer")
samp <- data.table::fread(samp, stringsAsFactors = FALSE) # reads in large datasets
msg <- system.file("extdata", "TJ_msg.xls", package = "gazer")
msg <- data.table::fread(msg, stringsAsFactors = FALSE) # reads in large datasets
setDT(samp)
setDT(msg)
DT_mesg <- msg[samp, on="time", roll="nearest"] # use this to get close to values in sample report
DT_mesg
#SR edfs are a nightmare. This makes it so messages are alined with closest values
get_msg <- DT_mesg %>%
group_by(trial, message) %>%
top_n(n=1, wt=desc(time)) # there are a lot of useless messages and they occupy the same time stamp. Only take the first message in time.
get_msg
@tjmahr
As I mentioned there are some issues with merging the sample and message data.
I am not going to make you download the SR API. I am attaching two ds, one with the samples and one with messages I am trying to merge. A lot of this is contained in the parse_edf function.