diff --git a/dashboard.Rmd b/dashboard.Rmd index c6625e6..16c0a18 100644 --- a/dashboard.Rmd +++ b/dashboard.Rmd @@ -918,11 +918,27 @@ fillCol( ) output$test_dy <- renderDygraph({ - test_ts <- test_query() + req(growth_counties) - dygraph(test_ts, main = "Normalized Aggregate Growth") %>% - dySeries("population_index", label = "Population") %>% - dySeries("housing_index", label = "Housing Units") %>% + aggregated_growth <- growth_counties() %>% + st_drop_geometry() %>% + group_by(year) %>% + summarize( + avg_normalized_population = mean(normalized_population, na.rm = TRUE), + avg_normalized_housing = mean(normalized_housing, na.rm = TRUE) + ) %>% + mutate(year = as.Date(paste0(year, "-01-01"))) + + result <- aggregated_growth %>% + select(year, avg_normalized_population, avg_normalized_housing) + + result_ts <- result %>% + select(-year) %>% + xts(order.by = result$year) + + dygraph(result_ts, main = "Normalized Growth") %>% + dySeries("avg_normalized_population", label = "Population", color = "red") %>% + dySeries("avg_normalized_housing", label = "Housing Units", color = "blue") %>% dyRangeSelector() })