Updtate text, add species data, add labels for professional.

This commit is contained in:
Nick Heppler 2025-02-12 12:55:49 -05:00
parent b25e1ba2c3
commit 4ae423f023

View File

@ -1,378 +1,418 @@
--- ---
title: "25 Million Trees Initiative Survey Report" title: "25 Million Trees Initiative Survey Report"
author: author:
- name: Nicholas Hepler <nicholas.hepler@its.ny.gov> - name: Nicholas Hepler <nicholas.hepler@its.ny.gov>
affiliation: Office of Information Technology Services affiliation: Office of Information Technology Services
- name: Annabel Gregg <annabel.gregg@dec.ny.gov> date: "`r format(Sys.Date(), '%B, %d, %Y')`"
affiliation: Department of Environmental Conservation keywords: "keyword1, keyword2"
date: "`r format(Sys.Date(), '%B, %d, %Y')`" output: html_document
output: html_document ---
---
```{r setup, include=FALSE}
```{r setup, include=FALSE} # Load necessary libraries
# Load necessary libraries library(tidyverse)
library(tidyverse) library(lubridate)
library(lubridate) library(ggplot2)
library(ggplot2)
# Read the CSV files into a dataframe
# Read the CSV file into a dataframe survey_path <- "data/_25_Million_Trees_Initiative_Survey_0.csv"
file_path <- "data/_25_Million_Trees_Initiative_Survey_0.csv" survey_data <- read_csv(survey_path)
survey_data <- read_csv(file_path)
species_path <- "data/species_planted_4.csv"
# Convert the CreationDate field to a proper datetime object (if applicable) species_data <- read.csv(species_path)
survey_data <- survey_data %>%
mutate(CreationDate = mdy_hms(CreationDate))
# Convert the CreationDate field to a proper datetime object (if applicable)
# Count the records to be excluded (Exclude Result == 1) survey_data <- survey_data %>%
excluded_count <- survey_data %>% mutate(CreationDate = mdy_hms(CreationDate))
filter(`Exclude Result` == 1) %>%
nrow() # Count the records to be excluded (Exclude Result == 1)
excluded_count <- survey_data %>%
# Count the records that are used (Exclude Result == 0) filter(`Exclude Result` == 1) %>%
used_count <- survey_data %>% nrow()
filter(`Exclude Result` == 0) %>%
nrow() # Count the records that are used (Exclude Result == 0)
used_count <- survey_data %>%
survey_data <- survey_data %>% filter(`Exclude Result` == 0) %>%
filter(`Exclude Result` == 0) nrow()
``` ```
# {.tabset .tabset-fade .tabset-pills} # {.tabset .tabset-fade .tabset-pills}
## Summary ## Summary
### Background ### 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. 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. 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. 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 ### Purpose
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: 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. - Summarize the overall progress of the initiative.
- Provide detailed data analysis on the submitted tree planting information. - Provide detailed data analysis on the submitted tree planting information.
- Identify areas where more outreach or support may be needed. - 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. 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.
## Submission Overview ## Submission Overview
This section contains information about surveys to the Tree Tracker Tool. This section provides an overview of the surveys submitted to the Tree Tracker Tool, detailing the survey period, exclusions, validation processes, and key data checks to ensure accuracy and consistency.
### Survey Period and Exclusions ### Survey Period and Exclusions
This report covers the 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")`**, with a total of **`r nrow(survey_data)`** records. Of these, **`r used_count`** records were included in the analysis. 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**: **`r excluded_count`** records have been excluded from the analysis. The primary reasons for exclusion include: Exclusions were applied to **`r excluded_count`** records, which were removed due to various reasons, such as:
- **Double Count**: Some records were excluded to prevent duplication of data (e.g., surveys or submissions that were entered multiple times).
- **Test Data**: Some submissions were excluded as they were entered for testing purposes and do not represent actual survey submissions. - **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 records are identified by the `Exclude Result` field, where a value of **1** indicates the record was excluded due to one of these reasons.
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.
- **Included Records**: **`r used_count`** records have been included in the report. These are valid survey submissions, marked with a value of **0** in the `Exclude Result` field, indicating they are legitimate data points.
---
### Survey Validation and Data Consistency abstract: "This report was generated on: **`r format(Sys.Date(), '%B, %d, %Y')`** for the following Reporting Period: **`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")`**. **`r used_count`** records were used in this analysis."
---
To ensure data integrity, several validation steps are applied to survey submissions:
### Survey Validation and Data Consistency
- **Required Fields**:
- **Number of Trees**: The number of trees planted is a required field, and users cannot submit the survey without providing this information. To ensure data integrity, several validation steps are applied to survey submissions:
- **Geographic Data**: Geographic coordinates (latitude and longitude) are also required, and users must provide this data when submitting their survey.
- **Required Fields**:
- **Geographic Validation**: Once geographic coordinates are entered, they are checked against official civil boundaries to ensure the accuracy of locality, county, and region data. In rare cases, this check may fail due to discrepancies in coordinates, but such records are corrected before inclusion in the analysis. - **Who Planted The Tree(s)?**: A descriptor of the particpant's role in the tree planting effort.
- **Number of Trees**: The number of trees planted is a required field, and users cannot submit the survey without providing this information.
- **Data Correction for Missing Information**: In cases where certain critical fields (such as geographic location or number of trees planted) are missing due to system issues, records are corrected prior to report generation. This ensures that only complete and accurate records are included in the analysis. - **Start Date of Planting**:
- **End Date of Planting**:
- **Date Logic**: - **Location**: Geographic coordinates (latitude and longitude) are also required, and users must provide this data when submitting their survey.
- **Program Start Date**: Users cannot enter planting dates prior to the official Program Start Date. The system enforces this restriction, and any records with such dates are not allowed to be submitted.
- **Response Validation**:
- **Format and Consistency Checks**: - **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.
- **Email Format**: The email addresses entered in the survey are validated to ensure they follow the correct format.
- **Optional Questions**: Even optional questions undergo validation to ensure the entered data meets the expected format or logic, providing further consistency and accuracy. - **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.
By applying these validation checks, the integrity and consistency of the data is ensured, allowing for meaningful analysis of tree planting surveys. - **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.
### Submission Trend
By applying these validation checks, the integrity and consistency of the data is ensured, allowing for meaningful analysis of tree planting surveys.
With this context in mind, the following visualization shows the trend in the total number of submissions over the survey period, highlighting any notable patterns.
### Submission Trend
```{r submission-trend, echo=FALSE, message=FALSE, fig.height=6, fig.width=8}
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.
library(ggplot2)
library(dplyr) ```{r submission-trend, echo=FALSE, message=FALSE, fig.height=6, fig.width=8}
survey_data$CreationDate <- as.Date(survey_data$CreationDate) library(ggplot2)
library(dplyr)
# Summarize the data to calculate the total number of submissions by CreationDate
summary_data <- survey_data %>% survey_data <- survey_data %>%
group_by(CreationDate) %>% filter(`Exclude Result` == 0)
summarise(total_submissions = n())
survey_data$CreationDate <- as.Date(survey_data$CreationDate)
ggplot(summary_data, aes(x = CreationDate, y = total_submissions)) +
geom_line(color = "#233f28", linewidth = 1) + # Change 'size' to 'linewidth' # Summarize the data to calculate the total number of submissions by CreationDate
geom_point(color = "#7e9084", size = 3) + summary_data <- survey_data %>%
geom_smooth(method = "loess", color = "#face00", linewidth = 1, linetype = "dashed") + group_by(CreationDate) %>%
labs( summarise(total_submissions = n())
title = "Total Number of Submissions by Date",
x = "Submission Date", ggplot(summary_data, aes(x = CreationDate, y = total_submissions)) +
y = "Total Number of Submissions" geom_line(color = "#233f28", linewidth = 1) + # Change 'size' to 'linewidth'
) + geom_point(color = "#7e9084", size = 3) +
theme_minimal(base_size = 14) + geom_smooth(method = "loess", color = "#face00", linewidth = 1, linetype = "dashed") +
theme( labs(
plot.title = element_text(size = 16, face = "bold", color = "#233f28"), title = "Total Number of Submissions by Date",
axis.title = element_text(size = 12, color = "#233f28"), x = "Submission Date",
axis.text = element_text(size = 10, color = "#233f28"), y = "Total Number of Submissions"
plot.margin = margin(10, 10, 10, 10), ) +
panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3), # Change 'size' to 'linewidth' theme_minimal(base_size = 14) +
panel.background = element_rect(fill = "#d9e1dd"), theme(
axis.text.x = element_text(angle = 45, hjust = 1) plot.title = element_text(size = 16, face = "bold", color = "#233f28"),
) + axis.title = element_text(size = 12, color = "#233f28"),
scale_x_date(date_labels = "%b %Y", date_breaks = "1 months") 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), # Change 'size' to 'linewidth'
### Response Rates panel.background = element_rect(fill = "#d9e1dd"),
The following table provides the response rates for a set of optional fields in the survey dataset. Each field represents a different aspect of the survey, and the response rate is calculated as the percentage of respondents who provided a valid answer. axis.text.x = element_text(angle = 45, hjust = 1)
) +
- **Planter Contact Email**: The percentage of respondents who provided their email address. scale_x_date(date_labels = "%b %Y", date_breaks = "1 months")
- **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. ### Response Rates
- **Source of Trees**: The percentage of respondents who reported the source of the trees they planted. 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.
- **Species Planted**: The percentage of respondents who provided the species of tree(s) they planted.
- **Planter Contact Email**: The percentage of respondents who provided their email address.
The data is sorted from the highest to the lowest response rate, allowing for easy identification of fields with higher or lower levels of respondent engagement. This helps to identify areas where respondents may have been more likely to provide answers, as well as fields that could benefit from clarification or further encouragement to respond. - **Funding Source**: The percentage of respondents who identified their funding source.
- **Land Ownership**: The percentage of respondents who indicated their land ownership status.
```{r response-rate, echo=FALSE, message=FALSE} - **Tree Size Planted**: The percentage of respondents who specified the size of trees they planted.
# List of fields to check for response rates, with special handling for 'Total Number of Species Planted' - **Source of Trees**: The percentage of respondents who reported the source of the trees they planted.
fields <- c("Planter Contact Email", "Funding Source", "Land Ownership", - **Species Planted**: The percentage of respondents who provided the species of tree(s) they planted.
"Tree Size Planted", "Source of Trees", "Total Number of Species 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.
# Calculate the response rate for each field
response_rates <- sapply(fields, function(field) { ```{r response-rate, echo=FALSE, message=FALSE}
if (field == "Total Number of Species Planted") { # List of fields to check for response rates, with special handling for 'Total Number of Species Planted'
# For "Total Number of Species Planted", consider answered if value is greater than 0 fields <- c("Planter Contact Email", "Funding Source", "Land Ownership",
sum(survey_data[[field]] > 0, na.rm = TRUE) / nrow(survey_data) * 100 "Tree Size Planted", "Source of Trees", "Total Number of Species Planted")
} else {
# For other fields, check for non-NA values # Calculate the response rate for each field
sum(!is.na(survey_data[[field]])) / nrow(survey_data) * 100 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
# Round the response rates to 2 decimal places } else {
response_rates_rounded <- round(response_rates, 2) # For other fields, check for non-NA values
sum(!is.na(survey_data[[field]])) / nrow(survey_data) * 100
# 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 # Round the response rates to 2 decimal places
sorted_response_rates 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)
## Participant Type Overview
# Print the sorted, rounded response rates
This section provides an overview of the different types of participants involved in tree planting surveys. The data collected includes submissions from various categories of participants, including state agencies, community organizations, private landowners, and municipal governments. By understanding the distribution of these participant types and the scope of their contributions, we can gain insights into the reach and diversity of the program. The following visualizations highlight the number of surveys and total trees planted by each participant type. sorted_response_rates
### Participant Type: 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.
## Participant Type Overview
```{r participant-type-surveys, echo=FALSE, message=FALSE}
library(ggplot2) This section provides an overview of the different types of participants involved in tree planting surveys. The data collected includes submissions from various categories of participants, including state agencies, community organizations, private landowners, and municipal governments. By understanding the distribution of these participant types and the scope of their contributions, we can gain insights into the reach and diversity of the program. The following visualizations highlight the number of surveys and total trees planted by each participant type.
library(dplyr)
### Participant Type: Number of Submissions
ggplot(survey_data, aes(x = `Who Planted The Tree(s)?`)) + 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.
geom_bar(fill = "#233f28", color = "#7e9084") +
geom_text(stat = "count", aes(label = scales::comma(after_stat(count))), ```{r participant-type-surveys, echo=FALSE, message=FALSE}
position = position_stack(vjust = 0.5), # Places text in the middle of the bars library(ggplot2)
color = "#ffffff", size = 5) + # Adjust label size library(dplyr)
labs(
title = "Number of Tree Planting Submissions by Participant Type", ggplot(survey_data, aes(x = `Who Planted The Tree(s)?`)) +
x = "Participant Type", geom_bar(fill = "#233f28", color = "#7e9084") +
y = "Number of Submissions" 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
scale_x_discrete(labels = c( color = "#ffffff", size = 5) + # Adjust label size
"agency" = "State Agency", labs(
"community" = "Community Organization", title = "Number of Tree Planting Submissions by Participant Type",
"landowner" = "Private Landowner", x = "Participant Type",
"municipality" = "Municipal Government" y = "Number of Submissions"
)) + ) +
theme_minimal(base_size = 14) + scale_x_discrete(labels = c(
theme( "agency" = "State Agency",
plot.title = element_text(size = 16, face = "bold", color = "#233f28"), "community" = "Community Organization",
axis.title = element_text(size = 12, color = "#233f28"), "landowner" = "Private Landowner",
axis.text = element_text(size = 10, color = "#233f28"), "municipality" = "Municipal Government",
plot.margin = margin(10, 10, 10, 10), "professional" = "Paid Professional"
panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3), )) +
panel.background = element_rect(fill = "#d9e1dd"), theme_minimal(base_size = 14) +
axis.text.x = element_text(angle = 45, hjust = 1) 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),
### Participant Type: Total Trees Planted panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3),
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. panel.background = element_rect(fill = "#d9e1dd"),
axis.text.x = element_text(angle = 45, hjust = 1)
```{r participant-type-planted, echo=FALSE, message=FALSE} )
library(ggplot2)
library(dplyr) ```
summary_data <- survey_data %>% ### Participant Type: Total Trees Planted
group_by(`Who Planted The Tree(s)?`) %>% 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.
summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE))
```{r participant-type-planted, echo=FALSE, message=FALSE}
library(ggplot2) library(ggplot2)
library(dplyr) library(dplyr)
# Assuming 'summary_data' is already defined summary_data <- survey_data %>%
ggplot(summary_data, aes(x = `Who Planted The Tree(s)?`, y = total_trees)) + group_by(`Who Planted The Tree(s)?`) %>%
geom_bar(stat = "identity", fill = "#233f28", color = "#7e9084") + summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE))
geom_text(aes(label = scales::comma(total_trees)),
position = position_stack(vjust = 0.5), # Places text in the middle of the bars library(ggplot2)
color = "#ffffff", size = 5) + # Accent color for text labels library(dplyr)
labs(
title = "Total Number of Trees Planted by Participant Type", # Assuming 'summary_data' is already defined
x = "Participant Type", ggplot(summary_data, aes(x = `Who Planted The Tree(s)?`, y = total_trees)) +
y = "Total Number of Trees Planted" geom_bar(stat = "identity", fill = "#233f28", color = "#7e9084") +
) + geom_text(aes(label = scales::comma(total_trees)),
scale_x_discrete(labels = c( position = position_stack(vjust = 0.5), # Places text in the middle of the bars
"agency" = "State Agency", color = "#ffffff", size = 5) + # Accent color for text labels
"community" = "Community Organization", labs(
"landowner" = "Private Landowner", title = "Total Number of Trees Planted by Participant Type",
"municipality" = "Municipal Government" x = "Participant Type",
)) + y = "Total Number of Trees Planted"
theme_minimal(base_size = 14) + # Adjusted base font size for clarity ) +
theme( scale_x_discrete(labels = c(
plot.title = element_text(size = 16, face = "bold", color = "#233f28"), "agency" = "State Agency",
axis.title = element_text(size = 12, color = "#233f28"), "community" = "Community Organization",
axis.text = element_text(size = 10, color = "#233f28"), "landowner" = "Private Landowner",
plot.margin = margin(10, 10, 10, 10), "municipality" = "Municipal Government",
panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3), "professional" = "Paid Professional"
panel.background = element_rect(fill = "#d9e1dd"), )) +
axis.text.x = element_text(angle = 45, hjust = 1) 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"),
```{r participant-type-table, echo=FALSE, message=FALSE} axis.text = element_text(size = 10, color = "#233f28"),
# Summarize the data to calculate the total number of trees planted by participant type plot.margin = margin(10, 10, 10, 10),
summary_data <- survey_data %>% panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3),
group_by(`Who Planted The Tree(s)?`) %>% panel.background = element_rect(fill = "#d9e1dd"),
summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE)) axis.text.x = element_text(angle = 45, hjust = 1)
# 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)?`, ```{r participant-type-table, echo=FALSE, message=FALSE}
"agency" = "State Agency", # Summarize the data to calculate the total number of trees planted by participant type
"community" = "Community Organization", summary_data <- survey_data %>%
"landowner" = "Private Landowner", group_by(`Who Planted The Tree(s)?`) %>%
"municipality" = "Municipal Government") summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE))
) # Replace the participant type values with more readable labels
summary_data <- summary_data %>%
# Add percentage column mutate(
summary_data <- summary_data %>% `Who Planted The Tree(s)?` = recode(`Who Planted The Tree(s)?`,
mutate(percentage = total_trees / sum(total_trees) * 100) "agency" = "State Agency",
"community" = "Community Organization",
# Format the table to display the number of trees and percentage "landowner" = "Private Landowner",
summary_data_formatted <- summary_data %>% "municipality" = "Municipal Government",
mutate( "professional" = "Paid Professional")
total_trees = scales::comma(total_trees), # Add commas to the total number of trees )
percentage = paste0(round(percentage, 1), "%") # Round percentage and append '%'
) # Add percentage column
summary_data <- summary_data %>%
# Print the table mutate(percentage = total_trees / sum(total_trees) * 100)
summary_data_formatted %>%
knitr::kable(col.names = c("Participant Type", "Total Trees Planted", "Percentage of Total Trees"), # Format the table to display the number of trees and percentage
caption = "Total Number of Trees Planted by Participant Type and their Proportional Contribution") %>% summary_data_formatted <- summary_data %>%
kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover")) mutate(
``` total_trees = scales::comma(total_trees), # Add commas to the total number of trees
percentage = paste0(round(percentage, 1), "%") # Round percentage and append '%'
)
## Region Overview
This section provides an overview of regional involved and response to the tree planting survey. # Print the table
summary_data_formatted %>%
In the table below, we aggregate plantings by Region. The results are provided in descending order of Total Trees Planted. knitr::kable(col.names = c("Participant Type", "Total Trees Planted", "Percentage of Total Trees"),
```{r region-summary, echo=FALSE, warning=FALSE, message=FALSE} caption = "Total Number of Trees Planted by Participant Type and their Proportional Contribution") %>%
# Summarize the data by Region kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover"))
region_summary_data <- survey_data %>% ```
group_by(Region) %>%
summarise(
total_records = n(), # Count the number of records in each region ## Region Overview
total_trees_planted = sum(`Number of Trees Planted`, na.rm = TRUE), # Sum of trees planted in each region This section provides an overview of regional involved and response to the tree planting survey.
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 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}
arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order # Summarize the data by Region
region_summary_data <- survey_data %>%
# Format the table to display the total number of records and trees planted group_by(Region) %>%
region_summary_data_formatted <- region_summary_data %>% summarise(
mutate( total_records = n(), # Count the number of records in each region
total_trees_planted = scales::comma(total_trees_planted), # Add commas to the total number of trees total_trees_planted = sum(`Number of Trees Planted`, na.rm = TRUE), # Sum of trees planted in each region
total_records = scales::comma(total_records), # Add commas to the total number of records mean_trees_planted = mean(`Number of Trees Planted`, na.rm = TRUE), # Mean number of trees planted
mean_trees_planted = round(mean_trees_planted, 1), # Round mean for readability median_trees_planted = median(`Number of Trees Planted`, na.rm = TRUE) # Median number of trees planted
median_trees_planted = round(median_trees_planted, 1) # Round median for readability ) %>%
) arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order
# Print the summary table # Format the table to display the total number of records and trees planted
region_summary_data_formatted %>% region_summary_data_formatted <- region_summary_data %>%
knitr::kable(col.names = c("Region", "Total Submissions", "Total Trees Planted", "Mean", "Median"), mutate(
caption = "Total Records, Trees Planted, Mean, and Median by Region (Sorted by Trees Planted)") %>% total_trees_planted = scales::comma(total_trees_planted), # Add commas to the total number of trees
kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover")) 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
)
## County Overview
This section provides an overview of counties involved and response to the tree planting survey. # Print the summary table
region_summary_data_formatted %>%
In the table below, we aggregate plantings by Region. The results are provided in descending order of Total Trees Planted. knitr::kable(col.names = c("Region", "Total Submissions", "Total Trees Planted", "Mean", "Median"),
```{r county-summary, echo=FALSE, warning=FALSE, message=FALSE} caption = "Total Records, Trees Planted, Mean, and Median by Region (Sorted by Trees Planted)") %>%
# Summarize the data by Region kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover"))
county_summary_data <- survey_data %>%
group_by(County) %>% ```
summarise(
total_records = n(), # Count the number of records in each county ## County Overview
total_trees_planted = sum(`Number of Trees Planted`, na.rm = TRUE), # Sum of trees planted in each region This section provides an overview of counties involved and response to the tree planting survey.
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 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}
arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order # Summarize the data by Region
county_summary_data <- survey_data %>%
# Format the table to display the total number of records and trees planted group_by(County) %>%
county_summary_data_formatted <- county_summary_data %>% summarise(
mutate( total_records = n(), # Count the number of records in each county
total_trees_planted = scales::comma(total_trees_planted), # Add commas to the total number of trees total_trees_planted = sum(`Number of Trees Planted`, na.rm = TRUE), # Sum of trees planted in each region
total_records = scales::comma(total_records), # Add commas to the total number of records mean_trees_planted = mean(`Number of Trees Planted`, na.rm = TRUE), # Mean number of trees planted
mean_trees_planted = round(mean_trees_planted, 1), # Round mean for readability median_trees_planted = median(`Number of Trees Planted`, na.rm = TRUE) # Median number of trees planted
median_trees_planted = round(median_trees_planted, 1) # Round median for readability ) %>%
) arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order
# Print the summary table # Format the table to display the total number of records and trees planted
county_summary_data_formatted %>% county_summary_data_formatted <- county_summary_data %>%
knitr::kable(col.names = c("County", "Total Submissions", "Total Trees Planted", "Mean", "Median"), mutate(
caption = "Total Records, Trees Planted, Mean, and Median by County (Sorted by Trees Planted)") %>% total_trees_planted = scales::comma(total_trees_planted), # Add commas to the total number of trees
kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover")) 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
)
## Tree Count
In this section, we present summary statistics for the number of trees planted by all participants in various tree planting surveys. # Print the summary table
county_summary_data_formatted %>%
```{r summary-stats, echo=FALSE, warning=FALSE, message=FALSE} knitr::kable(col.names = c("County", "Total Submissions", "Total Trees Planted", "Mean", "Median"),
# Calculate summary statistics caption = "Total Records, Trees Planted, Mean, and Median by County (Sorted by Trees Planted)") %>%
summary_stats <- summary(survey_data$`Number of Trees Planted`, na.rm = TRUE) kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover"))
```
```
Below is a summary of the `Number of Trees Planted` across participants:
| Statistic | Value | ## 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.
| Min | `r summary_stats["Min"]` |
| 1st Qu. | `r summary_stats["1st Qu."]` | ```{r species-detail, echo=FALSE, message=FALSE}
| Median | `r summary_stats["Median"]` | # Load the required libraries
| Mean | `r summary_stats["Mean"]` | library(tidyverse)
| 3rd Qu. | `r summary_stats["3rd Qu."]` | # Count unique values in 'Generic.Species.of.Tree' and 'Precise.Species.of.Tree', handling NA and sorting
| Max | `r summary_stats["Max"]` | generic_species_count <- species_data %>%
count(`Generic.Species.of.Tree`) %>%
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. 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.