Add support for multi device participants
parent
3aa037f031
commit
545d8a5ffe
|
@ -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")))
|
||||
|
|
Loading…
Reference in New Issue