rapids/src/data/phone_yielded_timestamps.R

19 lines
632 B
R
Raw Normal View History

2020-10-07 17:51:31 +02:00
source("renv/activate.R")
library("dplyr", warn.conflicts = F)
2020-10-07 17:51:31 +02:00
library(readr)
library(tidyr)
library(purrr)
2021-03-05 23:49:37 +01:00
options(scipen=999)
2020-10-07 17:51:31 +02:00
all_sensors = snakemake@input[["all_sensors"]]
sensor_timestamps <- tibble(files = all_sensors) %>%
2021-03-05 23:49:37 +01:00
mutate(timestamps = map(files,~ read_csv(.,col_types = cols_only(timestamp = col_double(), device_id = col_character()))),
2020-10-07 17:51:31 +02:00
sensor = row_number(),
files = NULL) %>%
unnest(timestamps) %>%
mutate(timestamp = (timestamp %/% 1000) * 1000) %>%
distinct(timestamp, .keep_all = TRUE) %>%
arrange(timestamp)
write.csv(sensor_timestamps, snakemake@output[[1]], row.names = FALSE)