2020-05-02 01:46:04 +02:00
source ( " renv/activate.R" )
2020-06-24 21:10:42 +02:00
source ( " src/features/bluetooth/bluetooth_base.R" )
2019-11-06 18:19:30 +01:00
library ( dplyr )
2020-04-27 23:55:23 +02:00
library ( tidyr )
2019-11-06 18:19:30 +01:00
2020-06-24 21:10:42 +02:00
bluetooth_data <- read.csv ( snakemake @ input [ [1 ] ] , stringsAsFactors = FALSE )
2019-11-06 18:19:30 +01:00
day_segment <- snakemake @ params [ [ " day_segment" ] ]
2020-04-03 19:07:09 +02:00
requested_features <- snakemake @ params [ [ " features" ] ]
2019-11-06 18:19:30 +01:00
features = data.frame ( local_date = character ( ) , stringsAsFactors = FALSE )
2020-06-24 21:10:42 +02:00
# Compute base bluetooth features
features <- merge ( features , base_bluetooth_features ( bluetooth_data , day_segment , requested_features ) , by = " local_date" , all = TRUE )
if ( ncol ( features ) != length ( requested_features ) + 1 )
stop ( paste0 ( " The number of features in the output dataframe (=" , ncol ( features ) , " ) does not match the expected value (=" , length ( requested_features ) , " + 1). Verify your bluetooth feature extraction functions" ) )
2019-11-06 18:19:30 +01:00
2020-04-27 23:55:23 +02:00
2019-11-06 18:19:30 +01:00
write.csv ( features , snakemake @ output [ [1 ] ] , row.names = FALSE )