Closed chayek closed 2 months ago
cleaned data folder link on GD: https://drive.google.com/drive/folders/1efz_Qq7sWOxRPs_RlrxXOdNOCFvS-8Qu?usp=drive_link
cleaned data file link on GD: https://drive.google.com/file/d/1x6tSossxL1WWUTPLOyDYTM6b2_kCnFWA/view?usp=drive_link
@npovejsil, @voglerdaniel, @Jihyeonbae, @Mbye20, @atkissoncj (sorry wasn't sure who to address this to) thanks for getting me these files!
I'm getting an error message about the left_join on line 281. I tried to fix it by changing the "by" input (when you give it a vector input, you are telling it to join by two commonly named columns present in both files, whereas, we want it to recognize that it is joining by two columns, one in each file, that have the same values so we need to use "join_by()" and the first one listed has to be the name in the first file)
data_sf <- shapefile %>% left_join(data, by= join_by(shape_key == data_key))
unfortunately, this didn't fix my issue and I am still getting the following error message when I try to run mapper:
<error/rlang_error> Error in
sf_column %in% names(g)
: ! Join columns inx
must be present in the data. ✖ Problem withshape_key
.Backtrace: ▆
my column names are entered as strings, and they are correct and indeed present in both files. not sure what the issue is :-(
Uploading the new cleaned files in a folder in GD momentarily. The code I tried to run was:
library(readr) library(tidyverse) library(tigris)
tell tigris to cache Census shapefile downloads
options(tigris_use_cache = FALSE)
Set working directory
workdir <- "C:/Users/carol/Documents/Water-Reuse-DSSG" setwd(workdir)
folder for saving figures and tables
image_folder <- "Analysis/Graphics/"
only run next line if you haven't created the folder yet
dir.create(image_folder)
drought_risk_path <- "Cleaned at Exisiting Scale/drought_risk.csv"
load cleaned multiyear drought risk data
drought_risk <- read.csv(drought_risk_path) %>%
correct county fips format to match tigris shapefile called
mutate(FIPS = str_pad(FIPS, 5, side = "left", pad = "0"))
mapper(drought_risk, counties(), variable_name = "NDC2NDI", data_key = "FIPS", shape_key = "GEOID", plot = "choropleth", map_path = image_folder)