knitr::opts_chunk$set(fig.width = 7, fig.height = 5)
# AirSensor2 package library(AirSensor2) # Set user's PurpleAir_API_READ_KEY source('/Users/jonathancallahan/Projects/MazamaScience/AirSensor2/global_vars.R') # Initialize spatial datasets initializeMazamaSpatialUtils() # Create a new 'pas' object for Okanogan county champaign_pas <- pas_createNew( api_key = PurpleAir_API_READ_KEY, countryCodes = "US", stateCodes = "IL", counties = c("Champaign"), lookbackDays = 365, # all sensors from the past year location_type = 0 # outdoor sensors only ) pas <- champaign_pas %>% pas_filter(sensor_index == "152934")
pas %>% pas_leaflet()
# Poplar & Holts sensor occasionally has some very high values # Create raw pat object pat <- pat_create( api_key = PurpleAir_API_READ_KEY, pas = champaign_pas, sensor_index = "152934", startdate = "2023-09-01", enddate = "2023-09-12", timezone = "UTC", verbose = TRUE ) tbl <- pat$data
#plot(tbl[,c(1,2:5)], pch = 15, cex = 0.5, main = "Sensor Electronics") layout(matrix(seq(4))) plot(tbl[,c(1,3)], pch = 15, cex = 0.5, main = "uptime") plot(tbl[,c(1,5)], pch = 15, cex = 0.5, main = "memory") plot(tbl[,c(1,2)], pch = 15, cex = 0.5, main = "wifi strength") plot(tbl[,c(1,4)], pch = 15, cex = 0.5, main = "latency") layout(1)
#plot(tbl[,c(1,6:8)], pch = 15, cex = 0.5, main = "Atmospheric Variables") layout(matrix(seq(3))) plot(tbl[,c(1,6)], pch = 15, cex = 0.5, main = "humidity") plot(tbl[,c(1,7)], pch = 15, cex = 0.5, main = "temperature") plot(tbl[,c(1,8)], pch = 15, cex = 0.5, main = "pressure") layout(1)
#plot(tbl[,c(1,12:14)], pch = 15, cex = 0.5, main = "PM2.5 'atm'") plot(tbl[,c(1,12)], pch = 15, cex = 0.5, col = "transparent", main = "pm2.5_atm") points(tbl[,c(1,13)], pch = 15, cex = 0.5, col = adjustcolor("blue", 0.3)) points(tbl[,c(1,14)], pch = 15, cex = 0.5, col = adjustcolor("red", 0.3))
correlation <- cor(tbl$pm2.5_atm_a, tbl$pm2.5_atm_b) %>% round(3) title <- sprintf("A/B Channel Correlation = %0.3f", correlation) plot(tbl[,c(13:14)], pch = 15, cex = 0.5, main = title)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.