Compare commits

..

3 Commits

View File

@ -318,8 +318,8 @@ The table below summarizes the response rates for optional top-level questions i
The "Total Number of Species Planted" question has special handling—only responses greater than 0 are considered valid, whereas for other questions, any non-NA value counts as a response. The "Total Number of Species Planted" question has special handling—only responses greater than 0 are considered valid, whereas for other questions, any non-NA value counts as a response.
```{r response-rate-table-optional, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r response-rate-table-optional, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
fields <- c("Planter Contact Email", "Funding Source", "Land Ownership", fields <- c("Planter Contact Email (Optional)", "Funding Source (Optional)", "Land Ownership (Optional)",
"Tree Size Planted", "Source of Trees", "Total Number of Species Planted") "Tree Size Planted (Optional)", "Source of Trees (Optional)", "Total Number of Species Planted")
calculate_response_rates(survey_data, fields, "Response Rates for Key Survey Questions") calculate_response_rates(survey_data, fields, "Response Rates for Key Survey Questions")
``` ```
@ -345,7 +345,7 @@ The following plot shows the distribution of survey submissions based on partici
```{r create-histogram-participant-type, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r create-histogram-participant-type, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
create_histogram( create_histogram(
survey_data, survey_data,
field = "Who Planted The Tree(s)?", field = "Who Planted The Tree(s)? (Required)",
x_labels = c( x_labels = c(
"agency" = "State Agency", "agency" = "State Agency",
"community" = "Community Organization", "community" = "Community Organization",
@ -421,7 +421,7 @@ create_bar_chart <- function(data, field, sum_field = NULL, x_labels = NULL, col
```{r create_bar_chart-participant-total-trees,echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r create_bar_chart-participant-total-trees,echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
create_bar_chart( create_bar_chart(
survey_data, survey_data,
field = "Who Planted The Tree(s)?", field = "Who Planted The Tree(s)? (Required)",
x_labels = c( x_labels = c(
"agency" = "State Agency", "agency" = "State Agency",
"community" = "Community Organization", "community" = "Community Organization",
@ -429,7 +429,7 @@ create_bar_chart(
"municipality" = "Municipal Government", "municipality" = "Municipal Government",
"professional" = "Paid Professional" "professional" = "Paid Professional"
), ),
sum_field = "Number of Trees Planted", sum_field = "Number of Trees Planted (Required)",
x_title = "Participant Type", x_title = "Participant Type",
y_title = "Total Trees Planted", y_title = "Total Trees Planted",
title = "Total Trees Planted by Participant Type", title = "Total Trees Planted by Participant Type",
@ -498,14 +498,14 @@ The following table provides a breakdown of the total number of trees planted by
```{r participant-type-table, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r participant-type-table, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
survey_data %>% survey_data %>%
mutate( mutate(
`Who Planted The Tree(s)?` = recode(`Who Planted The Tree(s)?`, `Who Planted The Tree(s)? (Required)` = recode(`Who Planted The Tree(s)? (Required)`,
"agency" = "State Agency", "agency" = "State Agency",
"community" = "Community Organization", "community" = "Community Organization",
"landowner" = "Private Landowner", "landowner" = "Private Landowner",
"municipality" = "Municipal Government", "municipality" = "Municipal Government",
"professional" = "Paid Professional") "professional" = "Paid Professional")
) %>% ) %>%
create_summary_table("Who Planted The Tree(s)?", "Number of Trees Planted", remove_na = FALSE, table_font_size = 16) create_summary_table("Who Planted The Tree(s)? (Required)", "Number of Trees Planted (Required)", remove_na = FALSE, table_font_size = 16)
``` ```
## Named User Activity ## Named User Activity
@ -513,7 +513,7 @@ survey_data %>%
```{r named-user-activity-table, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r named-user-activity-table, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
survey_data %>% survey_data %>%
mutate(Creator = ifelse(is.na(Creator), "Public User", Creator)) %>% mutate(Creator = ifelse(is.na(Creator), "Public User", Creator)) %>%
create_summary_table("Creator", "Number of Trees Planted", remove_na = FALSE, table_font_size = 16) create_summary_table("Creator", "Number of Trees Planted (Required)", remove_na = FALSE, table_font_size = 16)
``` ```
## Unique E-mail Activity ## Unique E-mail Activity
@ -521,21 +521,21 @@ survey_data %>%
```{r unique-email-activity-table, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r unique-email-activity-table, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
survey_data %>% survey_data %>%
mutate(Creator = ifelse(is.na(`Planter Contact Email`), "Not Provided", `Planter Contact Email`)) %>% mutate(Creator = ifelse(is.na(`Planter Contact Email (Optional)`), "Not Provided", `Planter Contact Email (Optional)`)) %>%
create_summary_table("Planter Contact Email", "Number of Trees Planted", remove_na = FALSE, table_font_size = 16) create_summary_table("Planter Contact Email (Optional)", "Number of Trees Planted (Required)", remove_na = FALSE, table_font_size = 16)
``` ```
## Municipal Activity ## Municipal Activity
```{r} ```{r}
survey_data %>% survey_data %>%
mutate(`Participant Municipality` = case_when( mutate(`Participant Municipality (Optional)` = case_when(
str_starts(`Participant Municipality`, "c_") ~ str_replace(`Participant Municipality`, "^c_", "") %>% paste0(" (city)"), str_starts(`Participant Municipality (Optional)`, "c_") ~ str_replace(`Participant Municipality (Optional)`, "^c_", "") %>% paste0(" (city)"),
str_starts(`Participant Municipality`, "v_") ~ str_replace(`Participant Municipality`, "^v_", "") %>% paste0(" (village)"), str_starts(`Participant Municipality (Optional)`, "v_") ~ str_replace(`Participant Municipality (Optional)`, "^v_", "") %>% paste0(" (village)"),
str_starts(`Participant Municipality`, "t_") ~ str_replace(`Participant Municipality`, "^t_", "") %>% paste0(" (town)"), str_starts(`Participant Municipality (Optional)`, "t_") ~ str_replace(`Participant Municipality (Optional)`, "^t_", "") %>% paste0(" (town)"),
TRUE ~ `Participant Municipality` TRUE ~ `Participant Municipality (Optional)`
)) %>% )) %>%
create_summary_table("Participant Municipality", "Number of Trees Planted", remove_na = FALSE, table_font_size = 16) create_summary_table("Participant Municipality (Optional)", "Number of Trees Planted (Required)", remove_na = FALSE, table_font_size = 16)
``` ```
## Organizaiton Activity ## Organizaiton Activity
@ -606,7 +606,7 @@ The map provides a visual overview of tree planting distribution across New York
```{r create-region-choropleth-map, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r create-region-choropleth-map, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
survey_data_aggregated <- survey_data %>% survey_data_aggregated <- survey_data %>%
group_by(Region) %>% group_by(Region) %>%
summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE)) summarise(total_trees = sum(`Number of Trees Planted (Required)`, na.rm = TRUE))
shapefile_path <- "/home/nick/gitea/tree-tracker-report/data/redc/redc.shp" shapefile_path <- "/home/nick/gitea/tree-tracker-report/data/redc/redc.shp"
@ -634,7 +634,7 @@ plot_geographic_data(joined_data = survey_data_joined,
``` ```
```{r create-summary-table-region, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r create-summary-table-region, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
create_summary_table(survey_data, "Region", "Number of Trees Planted", remove_na = FALSE, table_font_size = 16) create_summary_table(survey_data, "Region", "Number of Trees Planted (Required)", remove_na = FALSE, table_font_size = 16)
``` ```
## By County ## By County
@ -650,7 +650,7 @@ The map provides a visual overview of tree planting distribution across New York
```{r create-county-choropleth-map, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r create-county-choropleth-map, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
survey_data_aggregated <- survey_data %>% survey_data_aggregated <- survey_data %>%
group_by(County) %>% group_by(County) %>%
summarise(total_trees = sum(`Number of Trees Planted`, na.rm = TRUE)) summarise(total_trees = sum(`Number of Trees Planted (Required)`, na.rm = TRUE))
geographic_data <- counties(state = "NY", cb = TRUE, progress = FALSE) %>% geographic_data <- counties(state = "NY", cb = TRUE, progress = FALSE) %>%
st_as_sf() %>% st_as_sf() %>%
@ -672,7 +672,7 @@ plot_geographic_data(joined_data = survey_data_joined,
``` ```
```{r create-summary-table-county, echo=TRUE, message=FALSE, , fig.height=6, fig.width=8} ```{r create-summary-table-county, echo=TRUE, message=FALSE, , fig.height=6, fig.width=8}
create_summary_table(survey_data, "County", "Number of Trees Planted", remove_na = FALSE, table_font_size = 16) create_summary_table(survey_data, "County", "Number of Trees Planted (Required)", remove_na = FALSE, table_font_size = 16)
``` ```
@ -745,7 +745,7 @@ The following table shows a breakdown of survey submissions by **Genus**. For ea
These figures provide an understanding of which genus are most commonly reported, how prevalent each genus is, and the proportion of surveys where no genus was specified. These figures provide an understanding of which genus are most commonly reported, how prevalent each genus is, and the proportion of surveys where no genus was specified.
```{r create-summary-table-genus, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r create-summary-table-genus, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
create_species_summary_table(species_planted, "Generic Species of Tree", "Tree Genus") create_species_summary_table(species_planted, "Generic Type of Tree (Optional)", "Tree Genus")
``` ```
## By Species ## By Species
@ -759,7 +759,7 @@ The following table shows a breakdown of survey submissions by **Species**. For
These figures provide an understanding of which species are most commonly reported, how prevalent each species is, and the proportion of surveys where no genus was specified. These figures provide an understanding of which species are most commonly reported, how prevalent each species is, and the proportion of surveys where no genus was specified.
```{r create-summary-table-species, echo=TRUE, message=FALSE, fig.height=6, fig.width=8} ```{r create-summary-table-species, echo=TRUE, message=FALSE, fig.height=6, fig.width=8}
create_species_summary_table(species_planted, "Precise Species of Tree", "Tree Species") create_species_summary_table(species_planted, "Tree Species (Optional)", "Tree Species")
``` ```
# Disadvantaged Communities {.tabset} # Disadvantaged Communities {.tabset}
@ -768,8 +768,8 @@ create_species_summary_table(species_planted, "Precise Species of Tree", "Tree S
```{r create-summary-table-region-dac, echo=TRUE, message=FALSE, , fig.height=6, fig.width=8} ```{r create-summary-table-region-dac, echo=TRUE, message=FALSE, , fig.height=6, fig.width=8}
survey_data %>% survey_data %>%
filter(`Disadvantaged Communities Indicator` == "Designated as DAC", na.rm = TRUE) %>% filter(!is.na(`Disadvantaged Communities Indicator`), na.rm = TRUE) %>%
create_summary_table("Region", "Number of Trees Planted", remove_na = FALSE, table_font_size = 16) create_summary_table("Region", "Number of Trees Planted (Required)", remove_na = FALSE, table_font_size = 16)
``` ```
@ -777,15 +777,14 @@ survey_data %>%
```{r create-summary-table-county-dac, echo=TRUE, message=FALSE, , fig.height=6, fig.width=8} ```{r create-summary-table-county-dac, echo=TRUE, message=FALSE, , fig.height=6, fig.width=8}
survey_data %>% survey_data %>%
filter(`Disadvantaged Communities Indicator` == "Designated as DAC", na.rm = TRUE) %>% filter(!is.na(`Disadvantaged Communities Indicator`), na.rm = TRUE) %>%
create_summary_table("County", "Number of Trees Planted", remove_na = FALSE, table_font_size = 16) create_summary_table("County", "Number of Trees Planted (Required)", remove_na = FALSE, table_font_size = 16)
``` ```
## By Municipality ## By Municipality
```{r create-summary-table-county-municipality, echo=TRUE, message=FALSE, , fig.height=6, fig.width=8} ```{r create-summary-table-county-municipality, echo=TRUE, message=FALSE, , fig.height=6, fig.width=8}
survey_data %>% survey_data %>%
filter(`Disadvantaged Communities Indicator` == "Designated as DAC", na.rm = TRUE) %>% filter(!is.na(`Disadvantaged Communities Indicator`), na.rm = TRUE) %>%
create_summary_table("Municipality", "Number of Trees Planted", remove_na = FALSE, table_font_size = 16) create_summary_table("Municipality", "Number of Trees Planted (Required)", remove_na = FALSE, table_font_size = 16)
``` ```