Compare commits
No commits in common. "cda23941aa90505585eb02731b4285cda0a3cf8a" and "4ae423f0239eb26c6999b6bcebf617d1753dd296" have entirely different histories.
cda23941aa
...
4ae423f023
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
data/
|
|
||||||
report.html
|
|
||||||
856
report.Rmd
856
report.Rmd
@ -1,438 +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 Convervation
|
keywords: "keyword1, keyword2"
|
||||||
date: "`r format(Sys.Date(), '%B, %d, %Y')`"
|
output: html_document
|
||||||
keywords: "keyword1, keyword2"
|
---
|
||||||
output:
|
|
||||||
html_document
|
```{r setup, include=FALSE}
|
||||||
---
|
# Load necessary libraries
|
||||||
|
library(tidyverse)
|
||||||
```{r setup, include=FALSE}
|
library(lubridate)
|
||||||
# Load necessary libraries
|
library(ggplot2)
|
||||||
library(tidyverse)
|
|
||||||
library(lubridate)
|
# Read the CSV files into a dataframe
|
||||||
library(ggplot2)
|
survey_path <- "data/_25_Million_Trees_Initiative_Survey_0.csv"
|
||||||
|
survey_data <- read_csv(survey_path)
|
||||||
# Read the CSV files into a dataframe
|
|
||||||
survey_path <- "data/_25_Million_Trees_Initiative_Survey_0.csv"
|
species_path <- "data/species_planted_4.csv"
|
||||||
survey_data <- read_csv(survey_path)
|
species_data <- read.csv(species_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 %>%
|
||||||
# Convert the CreationDate field to a proper datetime object (if applicable)
|
mutate(CreationDate = mdy_hms(CreationDate))
|
||||||
survey_data <- survey_data %>%
|
|
||||||
mutate(CreationDate = mdy_hms(CreationDate))
|
# Count the records to be excluded (Exclude Result == 1)
|
||||||
|
excluded_count <- survey_data %>%
|
||||||
# Count the records to be excluded (Exclude Result == 1)
|
filter(`Exclude Result` == 1) %>%
|
||||||
excluded_count <- survey_data %>%
|
nrow()
|
||||||
filter(`Exclude Result` == 1) %>%
|
|
||||||
nrow()
|
# Count the records that are used (Exclude Result == 0)
|
||||||
|
used_count <- survey_data %>%
|
||||||
# Count the records that are used (Exclude Result == 0)
|
filter(`Exclude Result` == 0) %>%
|
||||||
used_count <- survey_data %>%
|
nrow()
|
||||||
filter(`Exclude Result` == 0) %>%
|
```
|
||||||
nrow()
|
|
||||||
```
|
# {.tabset .tabset-fade .tabset-pills}
|
||||||
|
|
||||||
---
|
## Summary
|
||||||
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."
|
|
||||||
---
|
### Background
|
||||||
|
|
||||||
# {.tabset .tabset-fade .tabset-pills}
|
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.
|
||||||
|
|
||||||
## Report Overview
|
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.
|
||||||
|
|
||||||
### Background
|
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.
|
||||||
|
|
||||||
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.
|
### Purpose
|
||||||
|
|
||||||
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 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 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.
|
- Summarize the overall progress of the initiative.
|
||||||
|
- Provide detailed data analysis on the submitted tree planting information.
|
||||||
### Purpose & Objectives
|
- Identify areas where more outreach or support may be needed.
|
||||||
|
|
||||||
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:
|
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.
|
||||||
|
|
||||||
- Summarize the overall progress of the initiative.
|
## Submission Overview
|
||||||
- Provide detailed data analysis on the submitted tree planting information.
|
|
||||||
- Identify areas where more outreach or support may be needed.
|
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.
|
||||||
|
|
||||||
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 Exclusions
|
||||||
|
|
||||||
### 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.
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
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.
|
||||||
- **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.
|
||||||
|
|
||||||
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.
|
---
|
||||||
|
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."
|
||||||
### Survey Validation Process and Data Consistency
|
---
|
||||||
|
|
||||||
To ensure data integrity, several validation steps are applied to survey submissions:
|
### Survey Validation and Data Consistency
|
||||||
|
|
||||||
- **Required Fields**:
|
To ensure data integrity, several validation steps are applied to survey submissions:
|
||||||
- **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.
|
- **Required Fields**:
|
||||||
- **Start Date of Planting**: The date when planting began.
|
- **Who Planted The Tree(s)?**: A descriptor of the particpant's role in the tree planting effort.
|
||||||
- **End Date of Planting**: The date when planting was completed.
|
- **Number of Trees**: The number of trees planted is a required field, and users cannot submit the survey without providing this information.
|
||||||
- **Location**: Geographic coordinates (latitude and longitude).
|
- **Start Date of Planting**:
|
||||||
|
- **End Date of Planting**:
|
||||||
- **Response Validation**:
|
- **Location**: Geographic coordinates (latitude and longitude) are also required, and users must provide this data when submitting their survey.
|
||||||
- **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.
|
- **Response Validation**:
|
||||||
- **Optional Questions**: Even optional questions undergo validation to ensure the entered data meets the expected format or logic, providing further consistency and accuracy.
|
- **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.
|
|
||||||
|
- **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 Analysis {.tabset}
|
|
||||||
|
By applying these validation checks, the integrity and consistency of the data is ensured, allowing for meaningful analysis of tree planting surveys.
|
||||||
### Submission Trend Analysis
|
|
||||||
|
### Submission Trend
|
||||||
```{r submission-trend-stats, echo=FALSE, message=FALSE}
|
|
||||||
## library(dplyr)
|
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.
|
||||||
|
|
||||||
# Ensure CreationDate is in Date format
|
```{r submission-trend, echo=FALSE, message=FALSE, fig.height=6, fig.width=8}
|
||||||
survey_data$CreationDate <- as.Date(survey_data$CreationDate)
|
|
||||||
|
library(ggplot2)
|
||||||
# Summarize the data to calculate the total number of submissions by CreationDate
|
library(dplyr)
|
||||||
summary_data <- survey_data %>%
|
|
||||||
filter(`Exclude Result` == 0) %>%
|
survey_data <- survey_data %>%
|
||||||
group_by(CreationDate) %>%
|
filter(`Exclude Result` == 0)
|
||||||
summarise(total_submissions = n(), .groups = "drop")
|
|
||||||
|
survey_data$CreationDate <- as.Date(survey_data$CreationDate)
|
||||||
# Number of days that have elapsed between the first and last submission date
|
|
||||||
date_range <- range(summary_data$CreationDate)
|
# Summarize the data to calculate the total number of submissions by CreationDate
|
||||||
elapsed_days <- as.integer(difftime(date_range[2], date_range[1], units = "days"))
|
summary_data <- survey_data %>%
|
||||||
|
group_by(CreationDate) %>%
|
||||||
# Number of days with 0 submissions
|
summarise(total_submissions = n())
|
||||||
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")
|
ggplot(summary_data, aes(x = CreationDate, y = total_submissions)) +
|
||||||
days_with_0_submissions <- sum(is.na(merged_data$total_submissions))
|
geom_line(color = "#233f28", linewidth = 1) + # Change 'size' to 'linewidth'
|
||||||
|
geom_point(color = "#7e9084", size = 3) +
|
||||||
# Summary statistics based on the count of submissions
|
geom_smooth(method = "loess", color = "#face00", linewidth = 1, linetype = "dashed") +
|
||||||
submission_summary <- summary(merged_data$total_submissions, na.rm = TRUE)
|
labs(
|
||||||
|
title = "Total Number of Submissions by Date",
|
||||||
# Dates where submissions exceeded the 3rd quartile
|
x = "Submission Date",
|
||||||
third_quartile <- quantile(merged_data$total_submissions, 0.75, na.rm = TRUE)
|
y = "Total Number of Submissions"
|
||||||
dates_above_3rd_quartile <- merged_data %>%
|
) +
|
||||||
filter(total_submissions > third_quartile) %>%
|
theme_minimal(base_size = 14) +
|
||||||
pull(CreationDate)
|
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"),
|
||||||
The survey has been active for **`r elapsed_days`** days.During this period **`r days_with_0_submissions`** days had no submission.
|
plot.margin = margin(10, 10, 10, 10),
|
||||||
|
panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3), # Change 'size' to 'linewidth'
|
||||||
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.
|
panel.background = element_rect(fill = "#d9e1dd"),
|
||||||
|
axis.text.x = element_text(angle = 45, hjust = 1)
|
||||||
```{r submission-trend-plot, echo=FALSE, message=FALSE, fig.height=6, fig.width=8}
|
) +
|
||||||
#library(ggplot2)
|
scale_x_date(date_labels = "%b %Y", date_breaks = "1 months")
|
||||||
|
```
|
||||||
# Plot Submission Trend
|
|
||||||
ggplot(summary_data, aes(x = CreationDate, y = total_submissions)) +
|
### Response Rates
|
||||||
geom_line(color = "#233f28", linewidth = 1) +
|
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.
|
||||||
geom_point(color = "#7e9084", size = 3) +
|
|
||||||
geom_smooth(method = "loess", color = "#face00", linewidth = 1, linetype = "dashed") +
|
- **Planter Contact Email**: The percentage of respondents who provided their email address.
|
||||||
labs(
|
- **Funding Source**: The percentage of respondents who identified their funding source.
|
||||||
title = "Total Number of Submissions by Date",
|
- **Land Ownership**: The percentage of respondents who indicated their land ownership status.
|
||||||
x = "Submission Date",
|
- **Tree Size Planted**: The percentage of respondents who specified the size of trees they planted.
|
||||||
y = "Total Number of Submissions"
|
- **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.
|
||||||
theme_minimal(base_size = 14) +
|
|
||||||
theme(
|
This breakdown helps identify which survey fields received higher levels of engagement, and which may require further clarification or encouragement to improve response rates.
|
||||||
plot.title = element_text(size = 16, face = "bold", color = "#233f28"),
|
|
||||||
axis.title = element_text(size = 12, color = "#233f28"),
|
```{r response-rate, echo=FALSE, message=FALSE}
|
||||||
axis.text = element_text(size = 10, color = "#233f28"),
|
# List of fields to check for response rates, with special handling for 'Total Number of Species Planted'
|
||||||
plot.margin = margin(10, 10, 10, 10),
|
fields <- c("Planter Contact Email", "Funding Source", "Land Ownership",
|
||||||
panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3),
|
"Tree Size Planted", "Source of Trees", "Total Number of Species Planted")
|
||||||
panel.background = element_rect(fill = "#d9e1dd"),
|
|
||||||
axis.text.x = element_text(angle = 45, hjust = 1)
|
# Calculate the response rate for each field
|
||||||
) +
|
response_rates <- sapply(fields, function(field) {
|
||||||
scale_x_date(date_labels = "%b %Y", date_breaks = "1 months")
|
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 {
|
||||||
### Survey Response Rates by Field
|
# For other fields, check for non-NA values
|
||||||
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.
|
sum(!is.na(survey_data[[field]])) / nrow(survey_data) * 100
|
||||||
|
}
|
||||||
- **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.
|
# Round the response rates to 2 decimal places
|
||||||
- **Tree Size Planted**: The percentage of respondents who specified the size of trees they planted.
|
response_rates_rounded <- round(response_rates, 2)
|
||||||
- **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.
|
# Sort the response rates in descending order (highest to lowest)
|
||||||
|
sorted_response_rates <- sort(response_rates_rounded, decreasing = TRUE)
|
||||||
This breakdown helps identify which survey fields received higher levels of engagement, and which may require further clarification or encouragement to improve response rates.
|
|
||||||
|
# Print the sorted, rounded response rates
|
||||||
```{r response-rate, echo=FALSE, message=FALSE}
|
sorted_response_rates
|
||||||
# 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")
|
|
||||||
|
## Participant Type Overview
|
||||||
# Calculate the response rate for each field
|
|
||||||
response_rates <- sapply(fields, function(field) {
|
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.
|
||||||
if (field == "Total Number of Species Planted") {
|
|
||||||
# For "Total Number of Species Planted", consider answered if value is greater than 0
|
### Participant Type: Number of Submissions
|
||||||
sum(survey_data[[field]] > 0, na.rm = TRUE) / nrow(survey_data) * 100
|
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.
|
||||||
} else {
|
|
||||||
# For other fields, check for non-NA values
|
```{r participant-type-surveys, echo=FALSE, message=FALSE}
|
||||||
sum(!is.na(survey_data[[field]])) / nrow(survey_data) * 100
|
library(ggplot2)
|
||||||
}
|
library(dplyr)
|
||||||
})
|
|
||||||
|
ggplot(survey_data, aes(x = `Who Planted The Tree(s)?`)) +
|
||||||
# Round the response rates to 2 decimal places
|
geom_bar(fill = "#233f28", color = "#7e9084") +
|
||||||
response_rates_rounded <- round(response_rates, 2)
|
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
|
||||||
# Sort the response rates in descending order (highest to lowest)
|
color = "#ffffff", size = 5) + # Adjust label size
|
||||||
sorted_response_rates <- sort(response_rates_rounded, decreasing = TRUE)
|
labs(
|
||||||
|
title = "Number of Tree Planting Submissions by Participant Type",
|
||||||
# Print the sorted, rounded response rates
|
x = "Participant Type",
|
||||||
sorted_response_rates
|
y = "Number of Submissions"
|
||||||
|
) +
|
||||||
```
|
scale_x_discrete(labels = c(
|
||||||
|
"agency" = "State Agency",
|
||||||
## Participant Type Analysis {.tabset}
|
"community" = "Community Organization",
|
||||||
|
"landowner" = "Private Landowner",
|
||||||
### Number of Submissions
|
"municipality" = "Municipal Government",
|
||||||
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.
|
"professional" = "Paid Professional"
|
||||||
|
)) +
|
||||||
```{r participant-type-surveys, echo=FALSE, message=FALSE}
|
theme_minimal(base_size = 14) +
|
||||||
#library(ggplot2)
|
theme(
|
||||||
#library(dplyr)
|
plot.title = element_text(size = 16, face = "bold", color = "#233f28"),
|
||||||
|
axis.title = element_text(size = 12, color = "#233f28"),
|
||||||
ggplot(survey_data, aes(x = `Who Planted The Tree(s)?`)) +
|
axis.text = element_text(size = 10, color = "#233f28"),
|
||||||
geom_bar(fill = "#233f28", color = "#7e9084") +
|
plot.margin = margin(10, 10, 10, 10),
|
||||||
geom_text(stat = "count", aes(label = scales::comma(after_stat(count))),
|
panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3),
|
||||||
position = position_stack(vjust = 0.5), # Places text in the middle of the bars
|
panel.background = element_rect(fill = "#d9e1dd"),
|
||||||
color = "#ffffff", size = 5) + # Adjust label size
|
axis.text.x = element_text(angle = 45, hjust = 1)
|
||||||
labs(
|
)
|
||||||
title = "Number of Tree Planting Submissions by Participant Type",
|
|
||||||
x = "Participant Type",
|
```
|
||||||
y = "Number of Submissions"
|
|
||||||
) +
|
### Participant Type: Total Trees Planted
|
||||||
scale_x_discrete(labels = c(
|
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.
|
||||||
"agency" = "State Agency",
|
|
||||||
"community" = "Community Organization",
|
```{r participant-type-planted, echo=FALSE, message=FALSE}
|
||||||
"landowner" = "Private Landowner",
|
library(ggplot2)
|
||||||
"municipality" = "Municipal Government",
|
library(dplyr)
|
||||||
"professional" = "Paid Professional"
|
|
||||||
)) +
|
summary_data <- survey_data %>%
|
||||||
theme_minimal(base_size = 14) +
|
group_by(`Who Planted The Tree(s)?`) %>%
|
||||||
theme(
|
summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE))
|
||||||
plot.title = element_text(size = 16, face = "bold", color = "#233f28"),
|
|
||||||
axis.title = element_text(size = 12, color = "#233f28"),
|
library(ggplot2)
|
||||||
axis.text = element_text(size = 10, color = "#233f28"),
|
library(dplyr)
|
||||||
plot.margin = margin(10, 10, 10, 10),
|
|
||||||
panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3),
|
# Assuming 'summary_data' is already defined
|
||||||
panel.background = element_rect(fill = "#d9e1dd"),
|
ggplot(summary_data, aes(x = `Who Planted The Tree(s)?`, y = total_trees)) +
|
||||||
axis.text.x = element_text(angle = 45, hjust = 1)
|
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(
|
||||||
### Total Trees Planted
|
title = "Total Number of Trees Planted by Participant Type",
|
||||||
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.
|
x = "Participant Type",
|
||||||
|
y = "Total Number of Trees Planted"
|
||||||
```{r participant-type-planted, echo=FALSE, message=FALSE}
|
) +
|
||||||
library(ggplot2)
|
scale_x_discrete(labels = c(
|
||||||
library(dplyr)
|
"agency" = "State Agency",
|
||||||
|
"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))
|
"professional" = "Paid Professional"
|
||||||
|
)) +
|
||||||
library(ggplot2)
|
theme_minimal(base_size = 14) + # Adjusted base font size for clarity
|
||||||
library(dplyr)
|
theme(
|
||||||
|
plot.title = element_text(size = 16, face = "bold", color = "#233f28"),
|
||||||
# Assuming 'summary_data' is already defined
|
axis.title = element_text(size = 12, color = "#233f28"),
|
||||||
ggplot(summary_data, aes(x = `Who Planted The Tree(s)?`, y = total_trees)) +
|
axis.text = element_text(size = 10, color = "#233f28"),
|
||||||
geom_bar(stat = "identity", fill = "#233f28", color = "#7e9084") +
|
plot.margin = margin(10, 10, 10, 10),
|
||||||
geom_text(aes(label = scales::comma(total_trees)),
|
panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3),
|
||||||
position = position_stack(vjust = 0.5), # Places text in the middle of the bars
|
panel.background = element_rect(fill = "#d9e1dd"),
|
||||||
color = "#ffffff", size = 5) + # Accent color for text labels
|
axis.text.x = element_text(angle = 45, hjust = 1)
|
||||||
labs(
|
)
|
||||||
title = "Total Number of Trees Planted by Participant Type",
|
```
|
||||||
x = "Participant Type",
|
|
||||||
y = "Total Number of Trees Planted"
|
```{r participant-type-table, echo=FALSE, message=FALSE}
|
||||||
) +
|
# Summarize the data to calculate the total number of trees planted by participant type
|
||||||
scale_x_discrete(labels = c(
|
summary_data <- survey_data %>%
|
||||||
"agency" = "State Agency",
|
group_by(`Who Planted The Tree(s)?`) %>%
|
||||||
"community" = "Community Organization",
|
summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE))
|
||||||
"landowner" = "Private Landowner",
|
# Replace the participant type values with more readable labels
|
||||||
"municipality" = "Municipal Government",
|
summary_data <- summary_data %>%
|
||||||
"professional" = "Paid Professional"
|
mutate(
|
||||||
)) +
|
`Who Planted The Tree(s)?` = recode(`Who Planted The Tree(s)?`,
|
||||||
theme_minimal(base_size = 14) + # Adjusted base font size for clarity
|
"agency" = "State Agency",
|
||||||
theme(
|
"community" = "Community Organization",
|
||||||
plot.title = element_text(size = 16, face = "bold", color = "#233f28"),
|
"landowner" = "Private Landowner",
|
||||||
axis.title = element_text(size = 12, color = "#233f28"),
|
"municipality" = "Municipal Government",
|
||||||
axis.text = element_text(size = 10, color = "#233f28"),
|
"professional" = "Paid Professional")
|
||||||
plot.margin = margin(10, 10, 10, 10),
|
)
|
||||||
panel.grid.major = element_line(color = "#d9e1dd", linewidth = 0.3),
|
|
||||||
panel.background = element_rect(fill = "#d9e1dd"),
|
# Add percentage column
|
||||||
axis.text.x = element_text(angle = 45, hjust = 1)
|
summary_data <- summary_data %>%
|
||||||
)
|
mutate(percentage = total_trees / sum(total_trees) * 100)
|
||||||
```
|
|
||||||
|
# Format the table to display the number of trees and percentage
|
||||||
```{r participant-type-table, echo=FALSE, message=FALSE}
|
summary_data_formatted <- summary_data %>%
|
||||||
# Summarize the data to calculate the total number of trees planted by participant type
|
mutate(
|
||||||
summary_data <- survey_data %>%
|
total_trees = scales::comma(total_trees), # Add commas to the total number of trees
|
||||||
group_by(`Who Planted The Tree(s)?`) %>%
|
percentage = paste0(round(percentage, 1), "%") # Round percentage and append '%'
|
||||||
summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE))
|
)
|
||||||
# Replace the participant type values with more readable labels
|
|
||||||
summary_data <- summary_data %>%
|
# Print the table
|
||||||
mutate(
|
summary_data_formatted %>%
|
||||||
`Who Planted The Tree(s)?` = recode(`Who Planted The Tree(s)?`,
|
knitr::kable(col.names = c("Participant Type", "Total Trees Planted", "Percentage of Total Trees"),
|
||||||
"agency" = "State Agency",
|
caption = "Total Number of Trees Planted by Participant Type and their Proportional Contribution") %>%
|
||||||
"community" = "Community Organization",
|
kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover"))
|
||||||
"landowner" = "Private Landowner",
|
```
|
||||||
"municipality" = "Municipal Government",
|
|
||||||
"professional" = "Paid Professional")
|
|
||||||
)
|
## Region Overview
|
||||||
|
This section provides an overview of regional involved and response to the tree planting survey.
|
||||||
# Add percentage column
|
|
||||||
summary_data <- summary_data %>%
|
In the table below, we aggregate plantings by Region. The results are provided in descending order of Total Trees Planted.
|
||||||
mutate(percentage = total_trees / sum(total_trees) * 100)
|
```{r region-summary, echo=FALSE, warning=FALSE, message=FALSE}
|
||||||
|
# Summarize the data by Region
|
||||||
# Format the table to display the number of trees and percentage
|
region_summary_data <- survey_data %>%
|
||||||
summary_data_formatted <- summary_data %>%
|
group_by(Region) %>%
|
||||||
mutate(
|
summarise(
|
||||||
total_trees = scales::comma(total_trees), # Add commas to the total number of trees
|
total_records = n(), # Count the number of records in each region
|
||||||
percentage = paste0(round(percentage, 1), "%") # Round percentage and append '%'
|
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
|
||||||
# Print the table
|
) %>%
|
||||||
summary_data_formatted %>%
|
arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order
|
||||||
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") %>%
|
# Format the table to display the total number of records and trees planted
|
||||||
kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover"))
|
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
|
||||||
## Region Overview
|
mean_trees_planted = round(mean_trees_planted, 1), # Round mean for readability
|
||||||
This section provides an overview of regional involved and response to the tree planting survey.
|
median_trees_planted = round(median_trees_planted, 1) # Round median for readability
|
||||||
|
)
|
||||||
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}
|
# Print the summary table
|
||||||
# Summarize the data by Region
|
region_summary_data_formatted %>%
|
||||||
region_summary_data <- survey_data %>%
|
knitr::kable(col.names = c("Region", "Total Submissions", "Total Trees Planted", "Mean", "Median"),
|
||||||
group_by(Region) %>%
|
caption = "Total Records, Trees Planted, Mean, and Median by Region (Sorted by Trees Planted)") %>%
|
||||||
summarise(
|
kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover"))
|
||||||
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
|
## County Overview
|
||||||
) %>%
|
This section provides an overview of counties involved and response to the tree planting survey.
|
||||||
arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order
|
|
||||||
|
In the table below, we aggregate plantings by County. The results are provided in descending order of Total Trees Planted.
|
||||||
# Format the table to display the total number of records and trees planted
|
```{r county-summary, echo=FALSE, warning=FALSE, message=FALSE}
|
||||||
region_summary_data_formatted <- region_summary_data %>%
|
# Summarize the data by Region
|
||||||
mutate(
|
county_summary_data <- survey_data %>%
|
||||||
total_trees_planted = scales::comma(total_trees_planted), # Add commas to the total number of trees
|
group_by(County) %>%
|
||||||
total_records = scales::comma(total_records), # Add commas to the total number of records
|
summarise(
|
||||||
mean_trees_planted = round(mean_trees_planted, 1), # Round mean for readability
|
total_records = n(), # Count the number of records in each county
|
||||||
median_trees_planted = round(median_trees_planted, 1) # Round median for readability
|
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
|
||||||
# Print the summary table
|
) %>%
|
||||||
region_summary_data_formatted %>%
|
arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order
|
||||||
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)") %>%
|
# Format the table to display the total number of records and trees planted
|
||||||
kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover"))
|
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
|
||||||
## County Overview
|
mean_trees_planted = round(mean_trees_planted, 1), # Round mean for readability
|
||||||
This section provides an overview of counties involved and response to the tree planting survey.
|
median_trees_planted = round(median_trees_planted, 1) # Round median for readability
|
||||||
|
)
|
||||||
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}
|
# Print the summary table
|
||||||
# Summarize the data by Region
|
county_summary_data_formatted %>%
|
||||||
county_summary_data <- survey_data %>%
|
knitr::kable(col.names = c("County", "Total Submissions", "Total Trees Planted", "Mean", "Median"),
|
||||||
group_by(County) %>%
|
caption = "Total Records, Trees Planted, Mean, and Median by County (Sorted by Trees Planted)") %>%
|
||||||
summarise(
|
kableExtra::kable_styling(full_width = F, position = "center", bootstrap_options = c("striped", "hover"))
|
||||||
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
|
|
||||||
) %>%
|
## Species Overview
|
||||||
arrange(desc(total_trees_planted)) # Sort by total trees planted in descending order
|
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.
|
||||||
|
|
||||||
# Format the table to display the total number of records and trees planted
|
```{r species-detail, echo=FALSE, message=FALSE}
|
||||||
county_summary_data_formatted <- county_summary_data %>%
|
# Load the required libraries
|
||||||
mutate(
|
library(tidyverse)
|
||||||
total_trees_planted = scales::comma(total_trees_planted), # Add commas to the total number of trees
|
# Count unique values in 'Generic.Species.of.Tree' and 'Precise.Species.of.Tree', handling NA and sorting
|
||||||
total_records = scales::comma(total_records), # Add commas to the total number of records
|
generic_species_count <- species_data %>%
|
||||||
mean_trees_planted = round(mean_trees_planted, 1), # Round mean for readability
|
count(`Generic.Species.of.Tree`) %>%
|
||||||
median_trees_planted = round(median_trees_planted, 1) # Round median for readability
|
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
|
||||||
# Print the summary table
|
`Generic.Species.of.Tree` = str_to_title(`Generic.Species.of.Tree`) # Convert to Title Case
|
||||||
county_summary_data_formatted %>%
|
) %>%
|
||||||
knitr::kable(col.names = c("County", "Total Submissions", "Total Trees Planted", "Mean", "Median"),
|
arrange(desc(n)) # Sort by count in descending order
|
||||||
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"))
|
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
|
||||||
## Species Overview
|
`Precise.Species.of.Tree` = str_to_title(`Precise.Species.of.Tree`) # Convert to Title Case
|
||||||
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.
|
) %>%
|
||||||
|
arrange(desc(n)) # Sort by count in descending order
|
||||||
```{r species-detail, echo=FALSE, message=FALSE}
|
|
||||||
#library(tidyverse)
|
# Print the results
|
||||||
# Count unique values in 'Generic.Species.of.Tree' and 'Precise.Species.of.Tree', handling NA and sorting
|
print(generic_species_count)
|
||||||
generic_species_count <- species_data %>%
|
print(precise_species_count)
|
||||||
count(`Generic.Species.of.Tree`) %>%
|
```
|
||||||
mutate(
|
|
||||||
`Generic.Species.of.Tree` = if_else(is.na(`Generic.Species.of.Tree`), "Null Response", `Generic.Species.of.Tree`),
|
## Tree Count
|
||||||
`Generic.Species.of.Tree` = str_replace_all(`Generic.Species.of.Tree`, "_", " "), # Replace underscores with spaces
|
In this section, we present summary statistics for the number of trees planted by all participants in various tree planting surveys.
|
||||||
`Generic.Species.of.Tree` = str_to_title(`Generic.Species.of.Tree`) # Convert to Title Case
|
|
||||||
) %>%
|
```{r summary-stats, echo=FALSE, warning=FALSE, message=FALSE}
|
||||||
arrange(desc(n)) # Sort by count in descending order
|
# Calculate summary statistics
|
||||||
|
summary_stats <- summary(survey_data$`Number of Trees Planted`, na.rm = TRUE)
|
||||||
precise_species_count <- species_data %>%
|
```
|
||||||
count(`Precise.Species.of.Tree`) %>%
|
|
||||||
mutate(
|
Below is a summary of the `Number of Trees Planted` across participants:
|
||||||
`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
|
| Statistic | Value |
|
||||||
`Precise.Species.of.Tree` = str_to_title(`Precise.Species.of.Tree`) # Convert to Title Case
|
|-------------|-------------|
|
||||||
) %>%
|
| Min | `r summary_stats["Min"]` |
|
||||||
arrange(desc(n)) # Sort by count in descending order
|
| 1st Qu. | `r summary_stats["1st Qu."]` |
|
||||||
|
| Median | `r summary_stats["Median"]` |
|
||||||
# Print the results
|
| Mean | `r summary_stats["Mean"]` |
|
||||||
print(generic_species_count)
|
| 3rd Qu. | `r summary_stats["3rd Qu."]` |
|
||||||
print(precise_species_count)
|
| 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.
|
||||||
## 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.
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user