diff --git a/app.R b/app.R index 3a7e9ce..13f09f1 100644 --- a/app.R +++ b/app.R @@ -424,23 +424,31 @@ server <- function(input, output) { ) ) }) + prep_mailing <- function(data) { + data |> + sf::st_drop_geometry() |> + dplyr::select(owner_1, owner_2, label) |> + dplyr::mutate( + owner_2 = dplyr::na_if(owner_2, "NA"), + owner_2 = ifelse(is.na(owner_2), "", owner_2), + label = stringr::str_squish(label), + city = "Venice", + state = "FL", + zip = "34285" + ) + } + output$download_filtered <- downloadHandler( filename = "st_andrews_owners_filtered.csv", content = function(file) { - filteredOwners() |> - sf::st_drop_geometry() |> - dplyr::select(owner_1, owner_2, label) |> - write.csv(file, row.names = FALSE) + write.csv(prep_mailing(filteredOwners()), file, row.names = FALSE) } ) output$download_all <- downloadHandler( filename = "st_andrews_owners_all.csv", content = function(file) { - owners |> - sf::st_drop_geometry() |> - dplyr::select(owner_1, owner_2, label) |> - write.csv(file, row.names = FALSE) + write.csv(prep_mailing(owners), file, row.names = FALSE) } )