###############################################################################
# Author: Gina, PhD student w/Sotiris (vnichols@iastate.edu)
# created: may 18 2020
# purpose: create sensordataXX for package data
# NOTES: only reads in things that have already gone through the sensordata-preprocess
# last updated:
#
###############################################################################
library(usethis)
library(dplyr)
library(readr)
library(readxl)
library(lubridate)
library(purrr)
library(tidyr)
data("inventory")
read_sensor_rds <- function(thepath){
tibble(filetmp = list.files(thepath)) %>%
mutate(pathtmp = paste0(thepath, filetmp)) %>%
mutate(data = pathtmp %>% map(read_rds)) %>%
unnest(cols = c(data)) %>%
filter(!is.na(value)) %>%
rename(logger_id = logger) %>%
mutate(date = date(date_time)) %>%
select(!contains("tmp"))
}
# 2018 --------------------------------------------------------------------
sd18 <- read_sensor_rds(thepath = "data-raw/sensordata/raw-files-rds/2018/")
#--merge it with the inventory
sensordata18 <-
sd18 %>%
#--join to inventory
left_join(filter(inventory %>%
mutate(sensor_type_simp = str_sub(sensor_type, 1, 3)),
year == 2018),
by = c("year", "logger_id", "sensor_port", "sensor_type_simp")) %>%
filter(date > date_in, date <= date_out)
sensordata18 %>%
filter(sensor_type_simp == "5TM")
use_data(sensordata18, overwrite = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.