Pull data for select sensors for all 2019

Functions in this package are designed to pull data for a single sensor on a single date. To get data spanning multiple sensors and dates efficiently, we can use vector and parallel processing to simultaneously access data.

library(tc.sensors)
library(dplyr)
library(magrittr)
library(furrr)
library(tictoc)

# pull sensor configuration and IDs
sensor_config <- pull_configuration()
sensor_ids <- pull_sensor_ids()

# start the timer
tic()

# set up parallel processing
future::plan(multisession)

# define date range
date_range <- seq(as.Date("2019/01/01"),
  as.Date("2019/12/31"),
  by = "days"
)

# iterate through each sensor
sensor_data <- furrr::future_map_dfr(
  sensor_ids[[1]][633:640],
  function(x) {
    # iterate through each date
    purrr::map_dfr(
      date_range,
      function(d) {
        pull_sensor(
          sensor = x,
          pull_date = d
        )
      }
    )
  }
)

tictoc::toc()

head(sensor_data)