Clarify setup chunk comments and fix data filtering order in Rmd.

This commit is contained in:
Nick Heppler 2025-05-09 10:43:32 -04:00
parent 73c3533850
commit d40c874921

View File

@ -65,7 +65,7 @@ participant_organizations <- read_csv(participants_path)
species_planted <- read_csv(species_path)
vendors <- read_csv(vendors_path)
# Convert character dates to POSIXct
# Convert relevant date columns to datetime format and recode planting agency responses to standardized labels
survey_data <- survey_data %>%
mutate(CreationDate = mdy_hms(CreationDate)) %>%
mutate(`Start Date of Planting (Required)` = mdy_hms(`Start Date of Planting (Required)`)) %>%
@ -77,6 +77,7 @@ survey_data <- survey_data %>%
"municipality" = "Municipal Government",
"professional" = "Paid Professional"))
# Derive and apply submission date from 'Survey ID' to replace 'CreationDate' when available
survey_data <- survey_data %>%
mutate(
Submitted_Date_Str = str_extract(`Survey ID`, "Submitted: \\d{2}-\\d{2}-\\d{2}") %>%
@ -98,14 +99,14 @@ survey_data <- survey_data %>%
) %>%
select(-Submitted_Date_Str, -Submitted_Date)
# Count and filter records based on exclusion flag
# Count and exclude flagged records, then summarize total and used counts, and determine submission date range
excluded_count <- survey_data %>% filter(`Exclude Result` == 1) %>% nrow()
survey_data <- survey_data %>%
filter(`Exclude Result` == 0)
start_date_submission <- format(min(survey_data$CreationDate, na.rm = TRUE), "%B %d, %Y")
end_date_submission <- format(max(survey_data$CreationDate, na.rm = TRUE), "%B %d, %Y")
excluded_count <- survey_data %>% filter(`Exclude Result` == 1) %>% nrow()
used_count <- survey_data %>% filter(`Exclude Result` == 0) %>% nrow()
total_records <- excluded_count + used_count
start_date_submission <- format(min(survey_data$CreationDate, na.rm = TRUE), "%B %d, %Y")
end_date_submission <- format(max(survey_data$CreationDate, na.rm = TRUE), "%B %d, %Y")
```
---