Add support for multi device participants

replace/0d752b42e873593d3135f0e8b5c02425e22ffe9d
JulioV 2019-12-17 13:41:27 -05:00
parent 3aa037f031
commit 545d8a5ffe
1 changed files with 6 additions and 3 deletions

View File

@ -9,13 +9,16 @@ group <- snakemake@params[["group"]]
table <- snakemake@params[["table"]]
sensor_file <- snakemake@output[[1]]
device_id <- readLines(participant, n=1)
device_ids <- readLines(participant, n=1)
unified_device_id <- tail(strsplit(device_ids, ",")[[1]], 1)
rmysql.settingsfile <- "./.env"
stopDB <- dbConnect(MySQL(), default.file = rmysql.settingsfile, group = group)
query <- paste("SELECT * FROM ", table, " WHERE device_id LIKE '", device_id, "'", sep = "")
query <- paste0("SELECT * FROM ", table, " WHERE device_id IN ('", gsub(",", "','", device_ids), "')")
sensor_data <- dbGetQuery(stopDB, query)
sensor_data <- sensor_data[order(sensor_data$timestamp),]
sensor_data <- sensor_data %>%
arrange(timestamp) %>%
mutate(device_id = unified_device_id)
# Droping duplicates on all columns except for _id
sensor_data <- sensor_data %>% distinct(!!!syms(setdiff(names(sensor_data), "_id")))