--- title: "25 Million Trees Initiative Survey Report" author: - name: Nicholas Hepler affiliation: Office of Information Technology Services - name: Annabel Gregg affiliation: Department of Environmental Convervation date: "`r format(Sys.Date(), '%B, %d, %Y')`" keywords: "keyword1, keyword2" output: html_document --- ```{r setup, include=FALSE} # Load necessary libraries library(tidyverse) library(lubridate) library(ggplot2) # Read the CSV files into a dataframe survey_path <- "data/_25_Million_Trees_Initiative_Survey_0.csv" survey_data <- read_csv(survey_path) species_path <- "data/species_planted_4.csv" species_data <- read.csv(species_path) # Convert the CreationDate field to a proper datetime object (if applicable) survey_data <- survey_data %>% mutate(CreationDate = mdy_hms(CreationDate)) # Count the records to be excluded (Exclude Result == 1) excluded_count <- survey_data %>% filter(`Exclude Result` == 1) %>% nrow() # Count the records that are used (Exclude Result == 0) used_count <- survey_data %>% filter(`Exclude Result` == 0) %>% nrow() ``` --- abstract: "This report was generated on: **`r format(Sys.Date(), '%B, %d, %Y')`**. For the period beginning : **`r format(min(survey_data$CreationDate, na.rm = TRUE), "%B %d, %Y")`** and ending: **`r format(max(survey_data$CreationDate, na.rm = TRUE), "%B %d, %Y")`**. **`r used_count`** records were used in this analysis." --- # {.tabset .tabset-fade .tabset-pills} ## Report Overview ### Background The **25 Million Trees Initiative** is a bold commitment launched by **Governor Kathy Hochul** during the 2024 State of the State Address, aiming to plant 25 million trees by 2033 in New York State. This initiative recognizes the critical importance of trees and forests for climate mitigation, enhancing community health, and supporting biodiversity. The New York State Department of Environmental Conservation (DEC) is at the forefront of tracking the progress of this ambitious goal. As part of this effort, DEC has launched the **Tree Tracker**, a tool for the public to record the trees they plant. These submissions contribute valuable data on the number, type, and locations of trees being planted across the state, helping to build a comprehensive, real-time dashboard of tree planting activities. This report compiles the survey data collected via the Tree Tracker and provides detailed insights into the information submitted by New Yorkers. It aims to support DEC staff and executives in understanding the progress of the initiative and identifying areas for improvement in outreach and engagement. ### Purpose & Objectives This report serves to present an overview of the data collected through the 25 Million Trees Initiative, offering insights into submission patterns, geographic distribution, and trends in tree planting activities. The report aims to: - Summarize the overall progress of the initiative. - Provide detailed data analysis on the submitted tree planting information. - Identify areas where more outreach or support may be needed. As more individuals contribute their data to the Tree Tracker, the initiative's success will be better understood, and DEC can better align resources to further promote this critical program. ### Survey Period and Data Exclusions The report covers the survey period from **`r format(min(survey_data$CreationDate, na.rm = TRUE), "%B %d, %Y")`** to **`r format(max(survey_data$CreationDate, na.rm = TRUE), "%B %d, %Y")`**, including a total of **`r nrow(survey_data)`** records. Out of these, **`r used_count`** records were deemed valid and included in the analysis. Exclusions were applied to **`r excluded_count`** records, which were removed due to various reasons, such as: - **Double Count**: Some submissions were identified as duplicates and excluded to prevent data redundancy. - **Test Data**: Entries that were intended solely for testing purposes were excluded, as they do not represent actual survey data. These excluded records are marked with a value of **1** in the `Exclude Result` field. The remaining **`r used_count`** records, marked with a **0**, represent legitimate data points that were included in the analysis. ### Survey Validation Process and Data Consistency To ensure data integrity, several validation steps are applied to survey submissions: - **Required Fields**: - **Who Planted the Tree(s)?**: Describes the participant's role in the tree planting effort. - **Number of Trees**: The number of trees planted during the planting period. - **Start Date of Planting**: The date when planting began. - **End Date of Planting**: The date when planting was completed. - **Location**: Geographic coordinates (latitude and longitude). - **Response Validation**: - **Geographic Validation**: Once geographic coordinates are entered, they are checked against official civil boundaries to provide an accurate nominal locality, county, and region data. In rare cases, this check may fail due to service dependency, but such records are corrected before inclusion in the analysis. - **Date Validation and Logic**: Users cannot enter planting dates prior to the start date of the initiative. The system enforces this restriction, and any records with such dates are not allowed to be submitted. Additionally, users cannot enter a planting end date that occurs before the planting start date. - **Optional Questions**: Even optional questions undergo validation to ensure the entered data meets the expected format or logic, providing further consistency and accuracy. - **Email Format**: The email addresses entered in the survey are validated to ensure they follow the correct format. By applying these validation checks, the integrity and consistency of the data is ensured, allowing for meaningful analysis of tree planting surveys. ## Submission Analysis {.tabset} ### Submission Trend Analysis ```{r submission-trend-stats, echo=FALSE, message=FALSE} ## library(dplyr) # Ensure CreationDate is in Date format survey_data$CreationDate <- as.Date(survey_data$CreationDate) # Summarize the data to calculate the total number of submissions by CreationDate summary_data <- survey_data %>% filter(`Exclude Result` == 0) %>% group_by(CreationDate) %>% summarise(total_submissions = n(), .groups = "drop") # Number of days that have elapsed between the first and last submission date date_range <- range(summary_data$CreationDate) elapsed_days <- as.integer(difftime(date_range[2], date_range[1], units = "days")) # Number of days with 0 submissions all_dates <- data.frame(CreationDate = seq.Date(date_range[1], date_range[2], by = "day")) merged_data <- left_join(all_dates, summary_data, by = "CreationDate") days_with_0_submissions <- sum(is.na(merged_data$total_submissions)) # Summary statistics based on the count of submissions submission_summary <- summary(merged_data$total_submissions, na.rm = TRUE) # Dates where submissions exceeded the 3rd quartile third_quartile <- quantile(merged_data$total_submissions, 0.75, na.rm = TRUE) dates_above_3rd_quartile <- merged_data %>% filter(total_submissions > third_quartile) %>% pull(CreationDate) ``` The survey has been active for **`r elapsed_days`** days.During this period **`r days_with_0_submissions`** days had no submission. The following visualization illustrates the trend in the total number of submissions throughout the survey period, providing insights into any patterns or changes in submission activity. ```{r submission-trend-plot, echo=FALSE, message=FALSE, fig.height=6, fig.width=8} #library(ggplot2) # Plot Submission Trend ggplot(summary_data, aes(x = CreationDate, y = total_submissions)) + geom_line(color = "#233f28", linewidth = 1) + geom_point(color = "#7e9084", size = 3) + geom_smooth(method = "loess", color = "#face00", linewidth = 1, linetype = "dashed") + labs( title = "Total Number of Submissions by Date", x = "Submission Date", y = "Total Number of Submissions" ) + theme_minimal(base_size = 14) + theme( plot.title = element_text(size = 16, face = "bold", color = "#233f28"), axis.title = element_text(size = 12, color = "#233f28"), axis.text = element_text(size = 10, color = "#233f28"), plot.margin = margin(10, 10, 10, 10), panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3), panel.background = element_rect(fill = "#d9e1dd"), axis.text.x = element_text(angle = 45, hjust = 1) ) + scale_x_date(date_labels = "%b %Y", date_breaks = "1 months") ``` ### Survey Response Rates by Field The table below shows the response rates for a selection of optional fields within the survey. Each field represents a different aspect of the survey, and the response rate reflects the percentage of respondents who provided valid answers for each field. - **Planter Contact Email**: The percentage of respondents who provided their email address. - **Funding Source**: The percentage of respondents who identified their funding source. - **Land Ownership**: The percentage of respondents who indicated their land ownership status. - **Tree Size Planted**: The percentage of respondents who specified the size of trees they planted. - **Source of Trees**: The percentage of respondents who reported the source of the trees they planted. - **Species Planted**: The percentage of respondents who provided the species of tree(s) they planted. This breakdown helps identify which survey fields received higher levels of engagement, and which may require further clarification or encouragement to improve response rates. ```{r response-rate, echo=FALSE, message=FALSE} # List of fields to check for response rates, with special handling for 'Total Number of Species Planted' fields <- c("Planter Contact Email", "Funding Source", "Land Ownership", "Tree Size Planted", "Source of Trees", "Total Number of Species Planted") # Calculate the response rate for each field response_rates <- sapply(fields, function(field) { if (field == "Total Number of Species Planted") { # For "Total Number of Species Planted", consider answered if value is greater than 0 sum(survey_data[[field]] > 0, na.rm = TRUE) / nrow(survey_data) * 100 } else { # For other fields, check for non-NA values sum(!is.na(survey_data[[field]])) / nrow(survey_data) * 100 } }) # Round the response rates to 2 decimal places response_rates_rounded <- round(response_rates, 2) # Sort the response rates in descending order (highest to lowest) sorted_response_rates <- sort(response_rates_rounded, decreasing = TRUE) # Print the sorted, rounded response rates sorted_response_rates ``` ## Participant Type Analysis {.tabset} ### Number of Submissions The first visualization shows the distribution of the number of tree planting surveys based on the participant type. This breakdown helps highlight which groups are contributing most to the tree planting initiative. ```{r participant-type-surveys, echo=FALSE, message=FALSE} #library(ggplot2) #library(dplyr) ggplot(survey_data, aes(x = `Who Planted The Tree(s)?`)) + geom_bar(fill = "#233f28", color = "#7e9084") + geom_text(stat = "count", aes(label = scales::comma(after_stat(count))), position = position_stack(vjust = 0.5), # Places text in the middle of the bars color = "#ffffff", size = 5) + # Adjust label size labs( title = "Number of Tree Planting Submissions by Participant Type", x = "Participant Type", y = "Number of Submissions" ) + scale_x_discrete(labels = c( "agency" = "State Agency", "community" = "Community Organization", "landowner" = "Private Landowner", "municipality" = "Municipal Government", "professional" = "Paid Professional" )) + theme_minimal(base_size = 14) + theme( plot.title = element_text(size = 16, face = "bold", color = "#233f28"), axis.title = element_text(size = 12, color = "#233f28"), axis.text = element_text(size = 10, color = "#233f28"), plot.margin = margin(10, 10, 10, 10), panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3), panel.background = element_rect(fill = "#d9e1dd"), axis.text.x = element_text(angle = 45, hjust = 1) ) ``` ### Total Trees Planted This second plot provides a breakdown of the total number of trees planted by participant type. This visualization helps to assess the contribution of each participant group to the overall impact of the tree planting program. ```{r participant-type-planted, echo=FALSE, message=FALSE} library(ggplot2) library(dplyr) summary_data <- survey_data %>% group_by(`Who Planted The Tree(s)?`) %>% summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE)) library(ggplot2) library(dplyr) # Assuming 'summary_data' is already defined ggplot(summary_data, aes(x = `Who Planted The Tree(s)?`, y = total_trees)) + geom_bar(stat = "identity", fill = "#233f28", color = "#7e9084") + geom_text(aes(label = scales::comma(total_trees)), position = position_stack(vjust = 0.5), # Places text in the middle of the bars color = "#ffffff", size = 5) + # Accent color for text labels labs( title = "Total Number of Trees Planted by Participant Type", x = "Participant Type", y = "Total Number of Trees Planted" ) + scale_x_discrete(labels = c( "agency" = "State Agency", "community" = "Community Organization", "landowner" = "Private Landowner", "municipality" = "Municipal Government", "professional" = "Paid Professional" )) + theme_minimal(base_size = 14) + # Adjusted base font size for clarity theme( plot.title = element_text(size = 16, face = "bold", color = "#233f28"), axis.title = element_text(size = 12, color = "#233f28"), axis.text = element_text(size = 10, color = "#233f28"), plot.margin = margin(10, 10, 10, 10), panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3), panel.background = element_rect(fill = "#d9e1dd"), axis.text.x = element_text(angle = 45, hjust = 1) ) ``` ```{r participant-type-table, echo=FALSE, message=FALSE} # Summarize the data to calculate the total number of trees planted by participant type summary_data <- survey_data %>% group_by(`Who Planted The Tree(s)?`) %>% summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE)) # Replace the participant type values with more readable labels summary_data <- summary_data %>% mutate( `Who Planted The Tree(s)?` = recode(`Who Planted The Tree(s)?`, "agency" = "State Agency", "community" = "Community Organization", "landowner" = "Private Landowner", "municipality" = "Municipal Government", "professional" = "Paid Professional") ) # Add percentage column summary_data <- summary_data %>% mutate(percentage = total_trees / sum(total_trees) * 100) # Format the table to display the number of trees and percentage summary_data_formatted <- summary_data %>% mutate( total_trees = scales::comma(total_trees), # Add commas to the total number of trees percentage = paste0(round(percentage, 1), "%") # Round percentage and append '%' ) # Print the table summary_data_formatted %>% knitr::kable(col.names = c("Participant Type", "Total Trees Planted", "Percentage of Total Trees"), caption = "Total Number of Trees Planted by Participant Type and their Proportional Contribution") %>% kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover")) ``` ## Region Overview This section provides an overview of regional involved and response to the tree planting survey. In the table below, we aggregate plantings by Region. The results are provided in descending order of Total Trees Planted. ```{r region-summary, echo=FALSE, warning=FALSE, message=FALSE} # Summarize the data by Region region_summary_data <- survey_data %>% group_by(Region) %>% summarise( total_records = n(), # Count the number of records in each region total_trees_planted = sum(`Number of Trees Planted`, na.rm = TRUE), # Sum of trees planted in each region mean_trees_planted = mean(`Number of Trees Planted`, na.rm = TRUE), # Mean number of trees planted median_trees_planted = median(`Number of Trees Planted`, na.rm = TRUE) # Median number of trees planted ) %>% arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order # Format the table to display the total number of records and trees planted region_summary_data_formatted <- region_summary_data %>% mutate( total_trees_planted = scales::comma(total_trees_planted), # Add commas to the total number of trees total_records = scales::comma(total_records), # Add commas to the total number of records mean_trees_planted = round(mean_trees_planted, 1), # Round mean for readability median_trees_planted = round(median_trees_planted, 1) # Round median for readability ) # Print the summary table region_summary_data_formatted %>% knitr::kable(col.names = c("Region", "Total Submissions", "Total Trees Planted", "Mean", "Median"), caption = "Total Records, Trees Planted, Mean, and Median by Region (Sorted by Trees Planted)") %>% kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover")) ``` ## County Overview This section provides an overview of counties involved and response to the tree planting survey. In the table below, we aggregate plantings by County. The results are provided in descending order of Total Trees Planted. ```{r county-summary, echo=FALSE, warning=FALSE, message=FALSE} # Summarize the data by Region county_summary_data <- survey_data %>% group_by(County) %>% summarise( total_records = n(), # Count the number of records in each county total_trees_planted = sum(`Number of Trees Planted`, na.rm = TRUE), # Sum of trees planted in each region mean_trees_planted = mean(`Number of Trees Planted`, na.rm = TRUE), # Mean number of trees planted median_trees_planted = median(`Number of Trees Planted`, na.rm = TRUE) # Median number of trees planted ) %>% arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order # Format the table to display the total number of records and trees planted county_summary_data_formatted <- county_summary_data %>% mutate( total_trees_planted = scales::comma(total_trees_planted), # Add commas to the total number of trees total_records = scales::comma(total_records), # Add commas to the total number of records mean_trees_planted = round(mean_trees_planted, 1), # Round mean for readability median_trees_planted = round(median_trees_planted, 1) # Round median for readability ) # Print the summary table county_summary_data_formatted %>% knitr::kable(col.names = c("County", "Total Submissions", "Total Trees Planted", "Mean", "Median"), caption = "Total Records, Trees Planted, Mean, and Median by County (Sorted by Trees Planted)") %>% kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover")) ``` ## Species Overview The following section contains details on species plantings. These results indicate the number of occurrences where the tree species was planted. They are not necessarily the number of those trees planted, but can be used to indicate popularity. ```{r species-detail, echo=FALSE, message=FALSE} #library(tidyverse) # Count unique values in 'Generic.Species.of.Tree' and 'Precise.Species.of.Tree', handling NA and sorting generic_species_count <- species_data %>% count(`Generic.Species.of.Tree`) %>% mutate( `Generic.Species.of.Tree` = if_else(is.na(`Generic.Species.of.Tree`), "Null Response", `Generic.Species.of.Tree`), `Generic.Species.of.Tree` = str_replace_all(`Generic.Species.of.Tree`, "_", " "), # Replace underscores with spaces `Generic.Species.of.Tree` = str_to_title(`Generic.Species.of.Tree`) # Convert to Title Case ) %>% arrange(desc(n)) # Sort by count in descending order precise_species_count <- species_data %>% count(`Precise.Species.of.Tree`) %>% mutate( `Precise.Species.of.Tree` = if_else(is.na(`Precise.Species.of.Tree`), "Null Response", `Precise.Species.of.Tree`), `Precise.Species.of.Tree` = str_replace_all(`Precise.Species.of.Tree`, "_", " "), # Replace underscores with spaces `Precise.Species.of.Tree` = str_to_title(`Precise.Species.of.Tree`) # Convert to Title Case ) %>% arrange(desc(n)) # Sort by count in descending order # Print the results print(generic_species_count) print(precise_species_count) ``` ## Tree Count In this section, we present summary statistics for the number of trees planted by all participants in various tree planting surveys. ```{r summary-stats, echo=FALSE, warning=FALSE, message=FALSE} # Calculate summary statistics summary_stats <- summary(survey_data$`Number of Trees Planted`, na.rm = TRUE) ``` Below is a summary of the `Number of Trees Planted` across participants: | Statistic | Value | |-------------|-------------| | Min | `r summary_stats["Min"]` | | 1st Qu. | `r summary_stats["1st Qu."]` | | Median | `r summary_stats["Median"]` | | Mean | `r summary_stats["Mean"]` | | 3rd Qu. | `r summary_stats["3rd Qu."]` | | Max | `r summary_stats["Max"]` | The summary statistics for the number of trees planted provide insight into the distribution of trees planted by all participants in the tree planting surveys. While the median value gives us a sense of the "typical" number of trees planted, the mean might be skewed by a few participants planting a very large number of trees.