mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
update ui to include more features
This commit is contained in:
@@ -150,6 +150,50 @@ get_normalized_cost_index <- function(storm, full_lf_id) {
|
||||
return(result)
|
||||
}
|
||||
|
||||
test_query <- function() {
|
||||
result <- dbGetQuery(con, "WITH yearly_totals AS (
|
||||
SELECT
|
||||
year,
|
||||
SUM(population) as total_population,
|
||||
SUM(housing_units) as total_housing_units
|
||||
FROM metrics.pop_and_housing
|
||||
WHERE state_fips = '12'
|
||||
AND county_fips IN ('011', '021', '086', '087')
|
||||
AND year BETWEEN 1926 AND 2024
|
||||
GROUP BY year
|
||||
),
|
||||
base_year AS (
|
||||
SELECT
|
||||
total_population as base_population,
|
||||
total_housing_units as base_housing
|
||||
FROM yearly_totals
|
||||
WHERE year = (SELECT MIN(year) FROM yearly_totals) -- Uses first year in dataset as base
|
||||
)
|
||||
SELECT
|
||||
year,
|
||||
total_population,
|
||||
total_housing_units,
|
||||
ROUND(total_population / base_population, 4) as population_index,
|
||||
ROUND(total_housing_units / base_housing, 4) as housing_index
|
||||
FROM yearly_totals
|
||||
CROSS JOIN base_year
|
||||
ORDER BY year;")
|
||||
|
||||
result <- result %>%
|
||||
mutate(
|
||||
year = as.Date(paste0(year, "-01-01"))
|
||||
) %>%
|
||||
select(
|
||||
year, population_index, housing_index
|
||||
)
|
||||
|
||||
result_ts <- result %>%
|
||||
select(-year) %>%
|
||||
xts(order.by = result$year)
|
||||
|
||||
return(result_ts)
|
||||
}
|
||||
|
||||
# returns landfalls and data at landfall from HURDAT
|
||||
get_hurdat_landfalls <- function(storm) {
|
||||
query <- view.hurdat_track %>%
|
||||
|
||||
Reference in New Issue
Block a user