-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from IDEELResearch/feature/covars
Feature/covars
- Loading branch information
Showing
11 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
library(sf) | ||
|
||
# variables needed for dataframe: lat, lon, time, num, denom, covar1 | ||
|
||
# find lat lon from stave -> merge with shp -> convert to df (remove geometries) | ||
|
||
covars <- readRDS(url("https://github.com/IDEELResearch/scrape/raw/refs/heads/main/analysis/data-derived/final_covariates.rds")) | ||
stave <- readRDS(url("https://github.com/IDEELResearch/stitch/raw/refs/heads/main/analysis/data_derived/mock_stave_prevalence.rds")) | ||
|
||
map_data <- get_map_covar_data(covars) | ||
|
||
stave %>% st_as_sf(coords = c("lon", "lat"), crs = 4326) %>% # EPSG:4326 for WGS84 | ||
ggplot() + | ||
geom_sf() + | ||
coord_sf() | ||
|
||
get_grff_input <- function(stave_obj, covar_obj){ | ||
|
||
covar_processed <- get_map_covar_data(covar_obj) | ||
covar_names <- covar_processed %>% select(-c(iso3c:year)) %>% st_drop_geometry() %>% names() | ||
|
||
sf_use_s2(FALSE) | ||
|
||
stave_obj %>% | ||
st_as_sf(coords = c("lon", "lat"), crs = 4326, remove = F) %>% # EPSG:4326 for WGS84 same as MAP shp files | ||
st_join(covar_processed, left = TRUE) %>% | ||
as.data.frame() %>% | ||
select(lat, lon, collection_day, numerator, denominator, year, all_of(covar_names)) %>% | ||
mutate(collection_year = year(as.Date(collection_day))) %>% | ||
filter(collection_year == year) %>% | ||
relocate(collection_year, .after = collection_day) %>% | ||
select(-year) | ||
|
||
} | ||
|
||
input_df <- get_grff_input(stave, covars) | ||
|
||
saveRDS(input_df, "analysis/data_derived/input_for_grff.rds") |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.