Did the number of treatments per year increase over time? (Figure 1a)

# Load data into R dataframes
TreatsOverTime <- sqlQuery(cnxn,
"SELECT tbl_treatment.Year_treated, Count(tbl_treatment.Year_treated) AS CountOfYear_treated FROM tbl_lakes
INNER JOIN (lu_treatment_goals INNER JOIN tbl_treatment ON lu_treatment_goals.Treatment_goal_id = tbl_treatment.Treatment_goal_id) ON tbl_lakes.LakeID = tbl_treatment.lakeid
GROUP BY tbl_treatment.Year_treated,
IIf([lu_treatment_goals].[Treatment_goal_id] In (1,3,4),'include','exclude')
HAVING (((IIf([lu_treatment_goals].[Treatment_goal_id] In (1,3,4),'include','exclude'))='include'));",
stringsAsFactors = FALSE) #excludes research projects

# Modify table
colnames(TreatsOverTime) =c("year", "treatmentNumber")
str(TreatsOverTime)
## 'data.frame':    14 obs. of  2 variables:
##  $ year           : num  2004 2005 2006 2008 2009 ...
##  $ treatmentNumber: int  1 1 1 1 1 2 6 3 2 3 ...
# View data
TreatsOverTime %>%
  kable() %>%
  kable_classic(full_width=F, html_font = "Times New Roman", c("striped", "hover"))
year treatmentNumber
2004 1
2005 1
2006 1
2008 1
2009 1
2011 2
2014 6
2015 3
2016 2
2017 3
2018 1
2019 2
2020 1
2021 2
# Check for normality
ggqqplot(TreatsOverTime$"treatmentNumber", ylab="treatmentNumber")

ggqqplot(TreatsOverTime$"year", ylab="year")

# Plot
Plot_TreatsPerYear <- ggplot(TreatsOverTime, aes(x=year, y=treatmentNumber, color='Projects')) +
  geom_smooth(method='lm', color='black') +
  geom_point(aes(x=year, y=treatmentNumber, color='Projects'), color='black') +
  theme_classic() +
  xlim(2004,2021) +
  ylim(-1,6.5) +
  labs(color='Legend', x="Year", y="Treatments (#)") #+
  #geom_text(x=2012, y=-1, size=3.5, aes(label="R = 0.28, p = 0.21"), color='black')

Plot_TreatsPerYear
## `geom_smooth()` using formula 'y ~ x'

# Kendall rank correlation test
r1 <- cor.test(TreatsOverTime$"treatmentNumber", TreatsOverTime$"year", method = "kendall", exact=FALSE)
r1
## 
##  Kendall's rank correlation tau
## 
## data:  TreatsOverTime$treatmentNumber and TreatsOverTime$year
## z = 1.2557, p-value = 0.2092
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##       tau 
## 0.2773501

Do the number of pre-treatment survey types increase over time? (Figure 1c)

# Load data into R dataframes
preTreat_trend <- sqlQuery(cnxn,
"SELECT tbl_treatment.Year_treated, tbl_lakes.Lake_name, Count(tbl_pretreatment_obs.observation_detail_id) AS CountOfobservation_detail_id, tbl_lakes.Eradication_WithinLT, tbl_treatment.Treatment_goal_id
FROM (tbl_lakes INNER JOIN (lu_treatment_goals INNER JOIN tbl_treatment ON lu_treatment_goals.Treatment_goal_id = tbl_treatment.Treatment_goal_id) ON tbl_lakes.LakeID = tbl_treatment.lakeid) INNER JOIN tbl_pretreatment_obs ON tbl_treatment.treatment_ID = tbl_pretreatment_obs.treatment_ID
GROUP BY tbl_treatment.Year_treated, tbl_lakes.Lake_name, tbl_pretreatment_obs.treatment_ID, tbl_lakes.Eradication_WithinLT, tbl_treatment.Treatment_goal_id
HAVING (((tbl_treatment.Treatment_goal_id)<>2));",
stringsAsFactors = FALSE) #excludes research projects

# Modify table
colnames(preTreat_trend) =c("yearTreated", "lakeName", "preTreatSurveys", "dreissenidPresence", "treatmentGoal")
preTreat_trend$treatmentGoal <- gsub("1", "EPE", preTreat_trend$treatmentGoal)
preTreat_trend$treatmentGoal <- gsub("3", "S", preTreat_trend$treatmentGoal)
preTreat_trend$treatmentGoal <- gsub("4", "RRE", preTreat_trend$treatmentGoal)
preTreat_trend$treatmentGoal <- as.factor(preTreat_trend$treatmentGoal) #Make categorical
preTreat_trend$dreissenidPresence <- as.factor(preTreat_trend$dreissenidPresence) #Make categorical
str(preTreat_trend)
## 'data.frame':    22 obs. of  5 variables:
##  $ yearTreated       : num  2004 2006 2008 2011 2011 ...
##  $ lakeName          : chr  "Lake Ossawinamakee" "Millbrook Quarry" "Base Lake" "Lake Irene" ...
##  $ preTreatSurveys   : int  4 3 2 3 4 4 2 3 1 1 ...
##  $ dreissenidPresence: Factor w/ 2 levels "Absent","Present": 2 1 2 2 2 2 2 2 2 2 ...
##  $ treatmentGoal     : Factor w/ 3 levels "EPE","RRE","S": 3 1 1 2 2 2 2 2 2 2 ...
# View data
preTreat_trend %>%
  kable() %>%
  kable_classic(full_width=F, html_font = "Times New Roman", c("striped", "hover"))
yearTreated lakeName preTreatSurveys dreissenidPresence treatmentGoal
2004 Lake Ossawinamakee 4 Present S
2006 Millbrook Quarry 3 Absent EPE
2008 Base Lake 2 Present EPE
2011 Lake Irene 3 Present RRE
2011 Rose Lake 4 Present RRE
2014 Christmas Lake 4 Present RRE
2014 Christmas Lake 2 Present RRE
2014 Christmas Lake 3 Present RRE
2014 Lake Independence 1 Present RRE
2014 Lake Winnipeg 1 Present RRE
2015 Lake Independence 3 Present RRE
2015 Ruth Lake 3 Present RRE
2016 Lake Minnewashta 3 Present RRE
2017 Billmeyer Quarry 2 Absent EPE
2017 Lake Marion 4 Present RRE
2017 Lake Minnewashta 5 Present RRE
2018 Richland Chambers Reservoir 1 Absent RRE
2019 Bone Lake 4 Present RRE
2019 Lake Minnetonka (SAB) 3 Present S
2020 Highland Lake 2 Present EPE
2021 Highland Lake 2 Present EPE
2021 Valley Lo Lake 2 Absent EPE
# Plot
preTreatGoalEPE <- subset(preTreat_trend, treatmentGoal %in% c('EPE'))
preTreatGoalS <- subset(preTreat_trend, treatmentGoal %in% c('S'))
preTreatGoalRRE <- subset(preTreat_trend, treatmentGoal %in% c('RRE'))

Plot_preTreat_trend <- ggplot(preTreatGoalRRE, aes(x=yearTreated, y=preTreatSurveys)) +
  geom_smooth(data=preTreatGoalRRE, method='lm', color="blue") +
  geom_smooth(data=preTreatGoalEPE, method='lm', color="red") +
  geom_point(data=preTreatGoalRRE, color="blue", size=2, shape=17) +
  geom_point(data=preTreatGoalEPE, color="red", size=2, shape=18) +
  theme_classic() +
  xlim(2004,2021) +
  ylim(0,5) +
  labs(x="Year", y="# pre-treatment \nsurvey methods") #+
  #geom_text(x=2008, y=0, size=3.5, aes(label="R = -0.60, p = 0.14"), color = "red") +
  #geom_text(x=2017, y=0, size=3.5, aes(label="R = 0.10, p = 0.73"), color = "blue")

Plot_preTreat_trend
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'

# Check for normality
ggqqplot(preTreatGoalEPE$"preTreatSurveys", ylab="preTreatSurveys")

ggqqplot(preTreatGoalEPE$"yearTreated", ylab="yearTreated") # not normal

ggqqplot(preTreatGoalRRE$"preTreatSurveys", ylab="preTreatSurveys")

ggqqplot(preTreatGoalRRE$"yearTreated", ylab="yearTreated")

ggqqplot(preTreatGoalS$"preTreatSurveys", ylab="preTreatSurveys")

ggqqplot(preTreatGoalS$"yearTreated", ylab="yearTreated")

# Pearson correlation test
r2EPE <- cor.test(preTreatGoalEPE$"preTreatSurveys", preTreatGoalEPE$"yearTreated", method = "kendall")
## Warning in cor.test.default(preTreatGoalEPE$preTreatSurveys,
## preTreatGoalEPE$yearTreated, : Cannot compute exact p-value with ties
r2EPE
## 
##  Kendall's rank correlation tau
## 
## data:  preTreatGoalEPE$preTreatSurveys and preTreatGoalEPE$yearTreated
## z = -1.4852, p-value = 0.1375
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##        tau 
## -0.5976143
r2RRE <- cor.test(preTreatGoalRRE$"preTreatSurveys", preTreatGoalRRE$"yearTreated", method = "pearson")
r2RRE
## 
##  Pearson's product-moment correlation
## 
## data:  preTreatGoalRRE$preTreatSurveys and preTreatGoalRRE$yearTreated
## t = 0.35507, df = 12, p-value = 0.7287
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.4531284  0.6000803
## sample estimates:
##       cor 
## 0.1019657

Has the size of the treated area relative to the entire lake changed over time? (Figure 1b)

# Load data into R dataframes
treatSize_lakeSize <- sqlQuery(cnxn,
"SELECT tbl_lakes.Lake_name, tbl_treatment.Year_treated, tbl_lakes.Area, tbl_treatment.Treat_Area, Round([tbl_treatment].[Treat_area]/[tbl_lakes].[area]*100,4) AS PercentTreatArea, tbl_lakes.Eradication_WithinLT, tbl_treatment.Treatment_goal_id
FROM tbl_lakes INNER JOIN (lu_treatment_goals INNER JOIN tbl_treatment ON lu_treatment_goals.Treatment_goal_id = tbl_treatment.Treatment_goal_id) ON tbl_lakes.LakeID = tbl_treatment.lakeid
GROUP BY tbl_lakes.Lake_name, tbl_treatment.treatment_ID, tbl_treatment.Year_treated, tbl_lakes.Area, tbl_treatment.Treat_Area, Round([tbl_treatment].[Treat_area]/[tbl_lakes].[area]*100,4), tbl_lakes.Eradication_WithinLT, tbl_treatment.Treatment_goal_id
HAVING (((tbl_treatment.Treatment_goal_id)=1 Or (tbl_treatment.Treatment_goal_id)=4));",
stringsAsFactors = FALSE) #excludes research and suppression projects

# Modify table
colnames(treatSize_lakeSize) =c("lakeName", "yearTreated", "lakeArea", "treatmentArea", "percentTreated", "dreissenidPresence", "treatmentGoal")
treatSize_lakeSize$treatmentGoal <- gsub("1", "EPE", treatSize_lakeSize$treatmentGoal)
treatSize_lakeSize$treatmentGoal <- gsub("4", "RRE", treatSize_lakeSize$treatmentGoal)
treatSize_lakeSize$treatmentGoal <- as.factor(treatSize_lakeSize$treatmentGoal) #Make categorical
treatSize_lakeSize$dreissenidPresence <- as.factor(treatSize_lakeSize$dreissenidPresence) #Make categorical
str(treatSize_lakeSize)
## 'data.frame':    24 obs. of  7 variables:
##  $ lakeName          : chr  "Base Lake" "Base Lake" "Billmeyer Quarry" "Bone Lake" ...
##  $ yearTreated       : num  2008 2009 2017 2019 2014 ...
##  $ lakeArea          : num  115 115 30 221 267 ...
##  $ treatmentArea     : num  115 115 14.8 0.57 0.07 0.75 0.75 0.75 11 1.5 ...
##  $ percentTreated    : num  100 100 49.3333 0.2574 0.0262 ...
##  $ dreissenidPresence: Factor w/ 2 levels "Absent","Present": 2 2 1 2 2 2 2 2 2 1 ...
##  $ treatmentGoal     : Factor w/ 2 levels "EPE","RRE": 1 1 1 2 2 2 2 2 2 1 ...
# View data
treatSize_lakeSize %>%
  kable() %>%
  kable_classic(full_width=F, html_font = "Times New Roman", c("striped", "hover"))
lakeName yearTreated lakeArea treatmentArea percentTreated dreissenidPresence treatmentGoal
Base Lake 2008 115.00 115.00 100.0000 Present EPE
Base Lake 2009 115.00 115.00 100.0000 Present EPE
Billmeyer Quarry 2017 30.00 14.80 49.3333 Absent EPE
Bone Lake 2019 221.45 0.57 0.2574 Present RRE
Christmas Lake 2014 267.17 0.07 0.0262 Present RRE
Christmas Lake 2014 267.17 0.75 0.2807 Present RRE
Christmas Lake 2014 267.17 0.75 0.2807 Present RRE
Christmas Lake 2014 267.17 0.75 0.2807 Present RRE
Christmas Lake 2015 267.17 11.00 4.1172 Present RRE
Crosley Lake 2016 3.00 1.50 50.0000 Absent EPE
Highland Lake 2020 102.80 39.00 37.9377 Present EPE
Highland Lake 2021 102.80 39.00 37.9377 Present EPE
Lake Independence 2014 832.02 0.50 0.0601 Present RRE
Lake Independence 2015 832.02 0.75 0.0901 Present RRE
Lake Irene 2011 639.26 10.00 1.5643 Present RRE
Lake Marion 2017 530.30 6.00 1.1314 Present RRE
Lake Minnewashta 2016 679.70 29.00 4.2666 Present RRE
Lake Minnewashta 2017 679.70 1.00 0.1471 Present RRE
Lake Winnipeg 2014 NA NA NA Present RRE
Millbrook Quarry 2006 12.00 12.00 100.0000 Absent EPE
Richland Chambers Reservoir 2018 41356.00 5.00 0.0121 Absent RRE
Rose Lake 2011 1200.47 10.00 0.8330 Present RRE
Ruth Lake 2015 599.20 2.89 0.4823 Present RRE
Valley Lo Lake 2021 28.00 14.00 50.0000 Absent EPE
# Plot
treatLakeEPE <- subset(treatSize_lakeSize, treatmentGoal %in% c('EPE'))
treatLakeRRE <- subset(treatSize_lakeSize, treatmentGoal %in% c('RRE'))

Plot_treatSize_lakeSize <- ggplot(treatLakeRRE, aes(x=yearTreated, y=percentTreated)) +
  geom_smooth(data=treatLakeRRE, method='lm', color="blue") +
  geom_smooth(data=treatLakeEPE, method='lm', color="red") +
  geom_point(data=treatLakeRRE, color="blue", size=2, shape=17) +
  geom_point(data=treatLakeEPE, color="red", size=2, shape=18) +
  theme_classic() +
  xlim(2004,2021) +
  ylim(-25,120) +
  labs(x="Year", y="Lake treated (%)") #+
  #geom_text(x=2008, y=-24, size=3.5, aes(label="R = -0.96, p = 0.0001"), color = "red") +
  #geom_text(x=2017, y=-24, size=3.5, aes(label="R = -0.10, p = 0.61"), color = "blue")

Plot_treatSize_lakeSize
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing missing values (geom_point).

# Check for normality
ggqqplot(treatLakeEPE$"yearTreated", ylab="yearTreated")

ggqqplot(treatLakeEPE$"percentTreated", ylab="percentTreated")

ggqqplot(treatLakeRRE$"yearTreated", ylab="yearTreated")

ggqqplot(treatLakeRRE$"percentTreated", ylab="percentTreated")
## Warning: Removed 1 rows containing non-finite values (stat_qq).
## Warning: Removed 1 rows containing non-finite values (stat_qq_line).

## Warning: Removed 1 rows containing non-finite values (stat_qq_line).

# Kendall rank correlation test
r3EPE <- cor.test(treatLakeEPE$"yearTreated", treatLakeEPE$"percentTreated", method = "pearson", exact=FALSE)
r3EPE
## 
##  Pearson's product-moment correlation
## 
## data:  treatLakeEPE$yearTreated and treatLakeEPE$percentTreated
## t = -8.7455, df = 6, p-value = 0.0001237
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.9934801 -0.8034764
## sample estimates:
##        cor 
## -0.9629427
r3RRE <- cor.test(treatLakeRRE$"yearTreated", treatLakeRRE$"percentTreated", method = "kendall", exact=FALSE)
r3RRE
## 
##  Kendall's rank correlation tau
## 
## data:  treatLakeRRE$yearTreated and treatLakeRRE$percentTreated
## z = -0.51112, p-value = 0.6093
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##        tau 
## -0.1043707

Does treatment size change with the number of pre-treatment surveys conducted? (included in text but not figure)

# Load data into R dataframes
PreTreatSurveyOverTime <- sqlQuery(cnxn,
                              "SELECT Count(tbl_pretreatment_obs.observation_detail_id) AS CountOfobservation_detail_id, tbl_treatment.Treat_Area
FROM (tbl_lakes INNER JOIN (lu_treatment_goals INNER JOIN tbl_treatment ON lu_treatment_goals.Treatment_goal_id = tbl_treatment.Treatment_goal_id) ON tbl_lakes.LakeID = tbl_treatment.lakeid) INNER JOIN tbl_pretreatment_obs ON tbl_treatment.treatment_ID = tbl_pretreatment_obs.treatment_ID
GROUP BY tbl_treatment.Treat_Area, tbl_lakes.Lake_name, tbl_treatment.Treatment_goal_id, tbl_treatment.treatment_ID
HAVING (((tbl_treatment.Treatment_goal_id)<>2));",
stringsAsFactors = FALSE) #excludes research projects

# Modify table
colnames(PreTreatSurveyOverTime) =c("Number of pre-treatment surveys", "Treatment area (acres)")

# View data
PreTreatSurveyOverTime %>%
  kable() %>%
  kable_classic(full_width=F, html_font = "Times New Roman", c("striped", "hover"))
Number of pre-treatment surveys Treatment area (acres)
1 NA
4 0.07
1 0.50
4 0.57
2 0.75
3 0.75
3 0.75
5 1.00
3 2.89
1 5.00
4 6.00
3 10.00
4 10.00
3 12.00
2 14.00
2 14.80
4 26.00
3 29.00
2 39.00
2 39.00
2 115.00
3 163.83
# Check for normality
ggqqplot(PreTreatSurveyOverTime$"Number of pre-treatment surveys", ylab="Number of pre-treatment surveys")

ggqqplot(PreTreatSurveyOverTime$"Treatment area (acres)", ylab="Treatment area (acres)")
## Warning: Removed 1 rows containing non-finite values (stat_qq).
## Warning: Removed 1 rows containing non-finite values (stat_qq_line).

## Warning: Removed 1 rows containing non-finite values (stat_qq_line).

# Kendall rank correlation test
r4 <- cor.test(PreTreatSurveyOverTime$"Number of pre-treatment surveys", PreTreatSurveyOverTime$"Treatment area (acres)", method = "kendall", exact=FALSE)
r4
## 
##  Kendall's rank correlation tau
## 
## data:  PreTreatSurveyOverTime$"Number of pre-treatment surveys" and PreTreatSurveyOverTime$"Treatment area (acres)"
## z = -1.0742, p-value = 0.2827
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##       tau 
## -0.185998

Figure for paper

plot <- ggarrange(Plot_TreatsPerYear, Plot_treatSize_lakeSize, Plot_preTreat_trend,
                    labels = c("a)", "b)", "c)"),
                    font.label = list(size = 11, color = "black", face = "bold", family = NULL),
                    align = c("h"),
                    ncol = 2, nrow = 2)
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
plot

Close and remove channel

close(cnxn)
rm(cnxn)

#♥ Session info

sessionInfo()
## R version 3.6.2 (2019-12-12)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19043)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=English_United States.1252 
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] RODBC_1.3-16      ggpubr_0.4.0      kableExtra_1.3.4  data.table_1.14.0
##  [5] forcats_0.5.1     stringr_1.4.0     dplyr_1.0.6       purrr_0.3.4      
##  [9] readr_1.4.0       tidyr_1.1.3       tibble_3.1.1      ggplot2_3.3.5    
## [13] tidyverse_1.3.1   knitr_1.36       
## 
## loaded via a namespace (and not attached):
##  [1] httr_1.4.2        jsonlite_1.7.2    viridisLite_0.4.0 splines_3.6.2    
##  [5] carData_3.0-4     modelr_0.1.8      assertthat_0.2.1  highr_0.9        
##  [9] cellranger_1.1.0  yaml_2.2.1        pillar_1.6.4      backports_1.2.1  
## [13] lattice_0.20-44   glue_1.4.2        digest_0.6.27     ggsignif_0.6.3   
## [17] rvest_1.0.2       colorspace_2.0-1  cowplot_1.1.1     htmltools_0.5.1.1
## [21] Matrix_1.3-3      pkgconfig_2.0.3   broom_0.7.10      haven_2.4.1      
## [25] scales_1.1.1      webshot_0.5.2     svglite_2.0.0     mgcv_1.8-35      
## [29] generics_0.1.1    farver_2.1.0      car_3.0-12        ellipsis_0.3.2   
## [33] withr_2.4.3       cli_2.5.0         magrittr_2.0.1    crayon_1.4.2     
## [37] readxl_1.3.1      evaluate_0.14     fs_1.5.0          fansi_0.4.2      
## [41] nlme_3.1-152      rstatix_0.7.0     xml2_1.3.2        tools_3.6.2      
## [45] hms_1.1.1         lifecycle_1.0.1   munsell_0.5.0     reprex_2.0.1     
## [49] compiler_3.6.2    jquerylib_0.1.4   systemfonts_1.0.2 rlang_0.4.11     
## [53] grid_3.6.2        rstudioapi_0.13   labeling_0.4.2    rmarkdown_2.11   
## [57] gtable_0.3.0      abind_1.4-5       DBI_1.1.2         R6_2.5.1         
## [61] lubridate_1.7.10  utf8_1.2.1        stringi_1.6.1     Rcpp_1.0.6       
## [65] vctrs_0.3.8       dbplyr_2.1.1      tidyselect_1.1.1  xfun_0.22