diff --git a/.Rproj.user/7D780DDE/pcs/source-pane.pper b/.Rproj.user/7D780DDE/pcs/source-pane.pper index a528f3b..902cc6f 100644 --- a/.Rproj.user/7D780DDE/pcs/source-pane.pper +++ b/.Rproj.user/7D780DDE/pcs/source-pane.pper @@ -1,3 +1,3 @@ { - "activeTab": -1 + "activeTab": 0 } \ No newline at end of file diff --git a/.Rproj.user/7D780DDE/pcs/windowlayoutstate.pper b/.Rproj.user/7D780DDE/pcs/windowlayoutstate.pper index 22c8e6e..b9d4a6d 100644 --- a/.Rproj.user/7D780DDE/pcs/windowlayoutstate.pper +++ b/.Rproj.user/7D780DDE/pcs/windowlayoutstate.pper @@ -1,9 +1,9 @@ { "left": { - "splitterpos": 274, - "topwindowstate": "HIDE", - "panelheight": 663, - "windowheight": 701 + "splitterpos": 277, + "topwindowstate": "NORMAL", + "panelheight": 672, + "windowheight": 710 }, "right": { "splitterpos": 418, diff --git a/.Rproj.user/7D780DDE/sources/prop/22A5BE1C b/.Rproj.user/7D780DDE/sources/prop/22A5BE1C index e8b0f93..8a43756 100644 --- a/.Rproj.user/7D780DDE/sources/prop/22A5BE1C +++ b/.Rproj.user/7D780DDE/sources/prop/22A5BE1C @@ -1,6 +1,6 @@ { "source_window_id": "", "Source": "Source", - "cursorPosition": "4,19", + "cursorPosition": "6,0", "scrollLine": "0" } \ No newline at end of file diff --git a/.Rproj.user/7D780DDE/sources/prop/2B3954DB b/.Rproj.user/7D780DDE/sources/prop/2B3954DB index 6f6d518..ee6f7bf 100644 --- a/.Rproj.user/7D780DDE/sources/prop/2B3954DB +++ b/.Rproj.user/7D780DDE/sources/prop/2B3954DB @@ -2,7 +2,7 @@ "tempName": "Untitled1", "source_window_id": "", "Source": "Source", - "cursorPosition": "193,0", - "scrollLine": "192", + "cursorPosition": "0,0", + "scrollLine": "0", "last_setup_crc32": "" } \ No newline at end of file diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/7D780DDE86301621/chunks.json b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/7D780DDE86301621/chunks.json new file mode 100644 index 0000000..90ce5c7 --- /dev/null +++ b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/7D780DDE86301621/chunks.json @@ -0,0 +1 @@ +{"chunk_definitions":[],"doc_write_time":1696232701} \ No newline at end of file diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/chunks.json b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/chunks.json index c7c98c9..90ce5c7 100644 --- a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/chunks.json +++ b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/chunks.json @@ -1 +1 @@ -{"chunk_definitions":[{"row":191,"row_count":1,"visible":true,"expansion_state":0,"options":{"engine":"r","label":"setup","include":true},"document_id":"845B7419","chunk_id":"csetup_chunk","chunk_label":"setup"}],"doc_write_time":1696229593,"working_dir":null,"default_chunk_options":{"echo":true},"chunk_rendered_width":700} \ No newline at end of file +{"chunk_definitions":[],"doc_write_time":1696232701} \ No newline at end of file diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000084.csv b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000084.csv deleted file mode 100644 index aa9f78d..0000000 --- a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000084.csv +++ /dev/null @@ -1,135 +0,0 @@ -"0","knitr::opts_chunk$set(echo = TRUE)" -"0","" -"0","# Load packages - I like to use the pacman package to do this more elegantly." -"0","if (!require(""pacman"")) install.packages(""pacman""); library(pacman)" -"2","Loading required package: pacman -" -"0","# The pacman package has a nice function 'p_load()' that will load the listed packages and install them if they are not already installed." -"0","p_load(DBI,RODBC,odbc,dbplyr,RMySQL,tidyverse,keyring,con2aqi,lubridate, stringr)" -"0","" -"0","# Check that MySQL is listed, if it isn't need to provide steps." -"0","sort(unique(odbcListDrivers()[[1]]))" -"1","[1]" -"1"," ""Microsoft Access Driver (*.mdb, *.accdb)"" " -"1"," -" -"1","[2]" -"1"," ""Microsoft Access Text Driver (*.txt, *.csv)"" " -"1"," -" -"1","[3]" -"1"," ""Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)""" -"1"," -" -"1","[4]" -"1"," ""MySQL ODBC 8.1 ANSI Driver"" " -"1"," -" -"1","[5]" -"1"," ""MySQL ODBC 8.1 Unicode Driver"" " -"1"," -" -"1","[6]" -"1"," ""SQL Server"" " -"1"," -" -"0","sql_conn <- dbConnect(RMySQL::MySQL()," -"0"," dbname = ""aaar2023tutorial""," -"0"," Server = ""localhost""," -"0"," port = 3306," -"0"," user = ""root""," -"0"," password = key_get(""MYSQL_PASSWORD"")" -"0"," )" -"0","initial_run=0" -"0","" -"0","if(initial_run==1){" -"0"," ## FIRST TIME ONLY!" -"0","# load some data" -"0","metadata <- read_csv(""data/example 1/metadata.csv"")" -"0","NO2_daily <- read_csv(""data/example 1/NO2_daily.csv"", col_types = cols(date = col_character())) %>% mutate(date=mdy(date), date=format(date,""%Y-%m-%d""))" -"0","" -"0","O3_daily <- read_csv(""data/example 1/O3_daily.csv"", col_types = cols(date = col_date(format = ""%m/%d/%Y"")))" -"0","PM_daily <- read_csv(""data/example 1/PM_daily.csv"", col_types = cols(date = col_date(format = ""%m/%d/%Y"")))" -"0","" -"0","# So that we can permit writing to SQL from R!" -"0","dbSendQuery(sql_conn, ""SET GLOBAL local_infile = true;"")" -"0","" -"0","# create a table in your SQL database" -"0","dbCreateTable(sql_conn,name=""no2_daily"", fields=NO2_daily)" -"0","dbCreateTable(sql_conn,name=""o3_daily"", fields=O3_daily)" -"0","dbCreateTable(sql_conn,name=""pm_daily"", fields=PM_daily)" -"0","" -"0","# write our data to the SQL database" -"0","dbWriteTable(sql_conn,""no2_daily"",NO2_daily,append=TRUE, row.names=FALSE)" -"0","dbWriteTable(sql_conn,""o3_daily"",O3_daily,append=TRUE, row.names=FALSE)" -"0","dbWriteTable(sql_conn,""pm_daily"",PM_daily,append=TRUE, row.names=FALSE)" -"0","" -"0","dbSendQuery(sql_conn,""ALTER TABLE no2_daily MODIFY date datetime;"")" -"0","dbSendQuery(sql_conn,""ALTER TABLE o3_daily MODIFY date datetime;"")" -"0","dbSendQuery(sql_conn,""ALTER TABLE pm_daily MODIFY date datetime;"")" -"0","}" -"0","" -"0","" -"0","" -"0","" -"0","# let's query our SQL in R! Let's say we are interested in calculating the AQI for the week of May 15 - 21, 2022 at the Mahon Park site (MP)" -"0","no2_db = tbl(sql_conn,""no2_daily"") %>% select(date,MP) %>% filter(between(date, as.Date('2022-05-15'), as.Date('2022-05-21'))) %>% show_query() %>% collect() %>% rename(NO2_MP = MP)" -"1"," -" -"1","SELECT `date`, `MP` -FROM `no2_daily` -WHERE (`date` BETWEEN CAST('2022-05-15' AS DATE) AND CAST('2022-05-21' AS DATE)) -" -"0","o3_db = tbl(sql_conn,""o3_daily"") %>% select(date,MP) %>% filter(between(date, as.Date('2022-05-15'), as.Date('2022-05-21'))) %>% show_query() %>% collect() %>% rename(O3_MP = MP)" -"1"," -" -"1","SELECT `date`, `MP` -FROM `o3_daily` -WHERE (`date` BETWEEN CAST('2022-05-15' AS DATE) AND CAST('2022-05-21' AS DATE)) -" -"0","pm_db = tbl(sql_conn,""pm_daily"") %>% select(date,MP) %>% filter(between(date, as.Date('2022-05-15'), as.Date('2022-05-21'))) %>% show_query() %>% collect() %>% rename(PM_MP = MP)" -"1"," -" -"1","SELECT `date`, `MP` -FROM `pm_daily` -WHERE (`date` BETWEEN CAST('2022-05-15' AS DATE) AND CAST('2022-05-21' AS DATE)) -" -"0","#let's put it together into one dataframe for our local analysis" -"0","aqi <- left_join(no2_db, o3_db, by='date') %>% left_join(., pm_db, by='date') %>% rowwise() %>%" -"0"," mutate(aqi = max(con2aqi(""pm25"",PM_MP),con2aqi(""o3"",O3_MP/1000,""8h""),con2aqi(""no2"",NO2_MP)))" -"0","" -"0","# maybe now we want to make a box plot of the no2 concentrations across sites!" -"0","no2_tidy = tbl(sql_conn,""no2_daily"") %>% select(-date) %>% show_query() %>% collect() %>% pivot_longer(everything(),names_to = ""site"", values_to = ""concentration"")" -"1"," -" -"1","SELECT - `R1001`, - `R1002`, - `R1004`, - `R1005`, - `R1008`, - `R1009`, - `R1011`, - `R1012`, - `R1039`, - `R1040`, - `R1041`, - `BS`, - `BK`, - `RS`, - `MP` -FROM `no2_daily` -" -"0","# Create a custom order for the 'site' variable" -"0","site_order <- c(""BS"", ""BK"", ""MP"",""RS"",""R1001"",""R1002"",""R1004"",""R1005"",""R1008"",""R1009"",""R1011"",""R1012"",""R1039"",""R1040"",""R1041"")" -"0","" -"0","# Make box plots for everything" -"0","no2_plot <- ggplot(no2_tidy, aes(x = factor(site, levels = site_order), y = concentration, fill=site)) +" -"0"," geom_boxplot() +" -"0"," labs(title = ""NO2 Concentrations by Site""," -"0"," x = ""Site""," -"0"," y = ""Concentration (ppb)"") +" -"0"," theme(axis.text.x = element_text(angle = 90, hjust = 1), legend.position=""none"") +" -"0"," scale_fill_discrete() +" -"0"," coord_cartesian(ylim = c(0,60))" -"0","no2_plot" diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000085.metadata b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000085.metadata deleted file mode 100644 index 459c681..0000000 --- a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000085.metadata +++ /dev/null @@ -1 +0,0 @@ -{"height":432.6328800988875,"width":700.0,"size_behavior":0,"conditions":[[1,"Warning: \u001B[38;5;232mRemoved 162 rows containing non-finite values (`stat_boxplot()`).\u001B[39m"]]} \ No newline at end of file diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000085.png b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000085.png deleted file mode 100644 index 4517b41..0000000 Binary files a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000085.png and /dev/null differ diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000085.snapshot b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000085.snapshot deleted file mode 100644 index abb87e2..0000000 Binary files a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000085.snapshot and /dev/null differ diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000086.csv b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000086.csv deleted file mode 100644 index a9b8478..0000000 --- a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000086.csv +++ /dev/null @@ -1,31 +0,0 @@ -"0","" -"0","o3_tidy = tbl(sql_conn,""o3_daily"") %>% select(-date) %>% show_query() %>% collect() %>% pivot_longer(everything(),names_to = ""site"", values_to = ""concentration"")" -"1"," -" -"1","SELECT - `R1001`, - `R1002`, - `R1004`, - `R1005`, - `R1008`, - `R1009`, - `R1011`, - `R1012`, - `R1039`, - `R1040`, - `R1041`, - `BS`, - `BK`, - `RS`, - `MP` -FROM `o3_daily` -" -"0","o3_plot <- ggplot(o3_tidy, aes(x = factor(site, levels = site_order), y = concentration, fill=site)) +" -"0"," geom_boxplot() +" -"0"," labs(title = ""O3 Concentrations by Site""," -"0"," x = ""Site""," -"0"," y = ""Concentration (ppb)"") +" -"0"," theme(axis.text.x = element_text(angle = 90, hjust = 1), legend.position=""none"") +" -"0"," scale_fill_discrete() +" -"0"," coord_cartesian(ylim = c(0,60))" -"0","o3_plot" diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000087.metadata b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000087.metadata deleted file mode 100644 index 459c681..0000000 --- a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000087.metadata +++ /dev/null @@ -1 +0,0 @@ -{"height":432.6328800988875,"width":700.0,"size_behavior":0,"conditions":[[1,"Warning: \u001B[38;5;232mRemoved 162 rows containing non-finite values (`stat_boxplot()`).\u001B[39m"]]} \ No newline at end of file diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000087.png b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000087.png deleted file mode 100644 index 9a22ef9..0000000 Binary files a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000087.png and /dev/null differ diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000087.snapshot b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000087.snapshot deleted file mode 100644 index 50d38e4..0000000 Binary files a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000087.snapshot and /dev/null differ diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000088.csv b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000088.csv deleted file mode 100644 index f186276..0000000 --- a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000088.csv +++ /dev/null @@ -1,31 +0,0 @@ -"0","" -"0","pm_tidy = tbl(sql_conn,""pm_daily"") %>% select(-date) %>% show_query() %>% collect() %>% pivot_longer(everything(),names_to = ""site"", values_to = ""concentration"")" -"1"," -" -"1","SELECT - `R1001`, - `R1002`, - `R1004`, - `R1005`, - `R1008`, - `R1009`, - `R1011`, - `R1012`, - `R1039`, - `R1040`, - `R1041`, - `BS`, - `BK`, - `RS`, - `MP` -FROM `pm_daily` -" -"0","pm_plot <- ggplot(pm_tidy, aes(x = factor(site, levels = site_order), y = concentration, fill=site)) +" -"0"," geom_boxplot() +" -"0"," labs(title = ""PM2.5 Concentrations by Site""," -"0"," x = ""Site""," -"0"," y = ""Concentration (ug/m3)"") +" -"0"," theme(axis.text.x = element_text(angle = 90, hjust = 1), legend.position=""none"") +" -"0"," scale_fill_discrete() +" -"0"," coord_cartesian(ylim = c(0,20))" -"0","pm_plot" diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000089.metadata b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000089.metadata deleted file mode 100644 index 0037351..0000000 --- a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000089.metadata +++ /dev/null @@ -1 +0,0 @@ -{"height":432.6328800988875,"width":700.0,"size_behavior":0,"conditions":[[1,"Warning: \u001B[38;5;232mRemoved 268 rows containing non-finite values (`stat_boxplot()`).\u001B[39m"]]} \ No newline at end of file diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000089.png b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000089.png deleted file mode 100644 index 501755b..0000000 Binary files a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/000089.png and /dev/null differ diff --git a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/00008b.metadata b/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/00008b.metadata deleted file mode 100644 index 8b459ef..0000000 --- a/.Rproj.user/shared/notebooks/D5B6EBA9-index/1/s/csetup_chunk/00008b.metadata +++ /dev/null @@ -1 +0,0 @@ -{"height":432.6328800988875,"width":700.0,"size_behavior":0,"conditions":[[0,"\u001B[38;5;232m`geom_line()`: Each group consists of only one observation.\n\u001B[36mℹ\u001B[38;5;232m Do you need to adjust the \u001B[32mgroup\u001B[38;5;232m aesthetic?\u001B[39m"]]} \ No newline at end of file