generated from SEFSC/SEFSC-Template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70c2707
commit 79a3b6f
Showing
19 changed files
with
284 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Community,PerDis,PopCom,Poverty,LabFrc_rev,HsChr_rev,RetMig,Region,PerDisCat,PopComCat,PovertyCat,LabFrc_revCat,HsChr_rev_Cat,RetMigCat | ||
Anna's Hope Village,-1.176896697,0.99090264,-0.259667405,-0.9170489,-0.870615185,,STX,1,3,1,1,1, | ||
Christiansted,1.301846855,1.444152684,-0.170368898,-0.764263051,0.341214512,,STX,4,4,1,1,2, | ||
East End,-1.698437867,-0.321161465,-0.467717579,-0.967969643,-2.130540715,,STX,1,1,1,1,1, | ||
Frederiksted,0.837638934,1.974876563,0.1670779,-0.382342636,0.387121151,,STX,3,4,2,1,2, | ||
Northcentral,0.26424226,1.229572578,0.337598754,-0.368558321,0.100798071,,STX,2,4,2,1,2, | ||
Sion Farm,-0.452424007,1.223593516,1.420789259,-0.663753628,-0.44302557,,STX,1,4,4,1,1, | ||
Southcentral,0.173472317,1.482803418,0.751435942,-0.338094566,0.096420823,,STX,2,4,3,1,2, | ||
Southwest,0.337343569,1.448786896,0.597807368,-0.157766842,-0.34565704,,STX,2,4,3,1,1, | ||
Central,-1.368875201,0.309238687,-1.092339903,-3.139525421,-1.913672875,,STJ,1,2,1,1,1, | ||
Coral Bay,-0.757670101,0.133811332,-1.066749483,-2.188775351,-1.97989363,,STJ,1,2,1,1,1, | ||
Charlotte Amalie,0.408769519,1.623093418,2.041794226,-1.443009104,0.001318479,,STT,2,4,4,1,2, | ||
East End,-0.447002294,0.973491259,-0.015688822,-2.032965938,-0.941160532,,STT,1,3,1,1,1, | ||
Northside,-1.687407787,0.129369568,-0.245941438,-2.303488256,-2.304720727,,STT,1,2,1,1,1, | ||
Tutu,-0.28251731,1.778627435,0.156103212,-0.645871444,-0.815893603,,STT,1,4,2,1,1, | ||
West End,-1.449026933,0.833301708,-0.583795443,-1.889673987,-1.37419037,,STT,1,3,1,1,1, | ||
Carolina,-0.110854843,2.695812455,0.865721931,0.574207992,0.908201112,,E,1,4,3,3,3, | ||
Cataño,2.453484211,3.424980479,2.498137672,0.591134591,1.276474399,,E,4,4,4,3,4, | ||
Dorado,0.392654795,2.517758481,1.355542351,0.827035851,-0.020524911,,E,2,4,4,3,1, | ||
Guaynabo,-0.094975956,2.244615592,0.814119904,0.009038192,-0.214489543,,E,1,4,3,2,1, | ||
Loíza,1.013028988,3.233907594,2.264068151,0.476485575,1.884196741,,E,4,4,4,2,4, | ||
Luquillo,1.232981647,2.672003549,2.234653573,0.62925987,1.622402107,,E,4,4,4,3,4, | ||
Manatí,1.137373307,2.645219819,2.700561523,1.606988054,1.9054336,,E,4,4,4,4,4, | ||
Río Grande,1.152622229,2.732515254,2.007938463,0.868968197,1.447681922,,E,4,4,4,3,4, | ||
San Juan,0.420795811,2.687289342,1.639229369,0.394891052,0.821240227,,E,2,4,4,2,3, | ||
Toa Baja,0.355842792,2.698261577,1.71416476,0.436562141,0.801013458,,E,2,4,4,2,3, | ||
Vega Alta,1.842169521,2.732802583,2.894681665,1.844853847,1.047595533,,E,4,4,4,4,4, | ||
Vega Baja,1.8717328,2.729194662,2.748812693,2.339881779,0.907036534,,E,4,4,4,4,3, | ||
Ceiba,1.538742352,2.5913295,2.222517548,1.208886454,1.936584722,,E,4,4,4,4,4, | ||
Culebra,-1.63411255,2.617729262,1.344372184,-0.03960046,1.904508336,,E,1,4,4,1,4, | ||
Fajardo,0.769311631,2.823961262,1.898622616,1.339968268,1.594835045,,E,3,4,4,4,4, | ||
Humacao,0.497870952,2.669663041,2.365912139,1.983676494,1.799016451,,E,2,4,4,4,4, | ||
Naguabo,0.660630368,2.43546516,2.860701162,2.027082803,2.090034456,,E,3,4,4,4,4, | ||
Vieques,0.627203058,2.666167542,2.379684436,1.510458588,2.025365021,,E,3,4,4,4,4, | ||
Yabucoa,1.937455788,2.806283026,2.764333474,2.307477969,1.990873598,,E,4,4,4,4,4, | ||
Arroyo,2.734200224,2.806570354,2.843312618,1.674529171,1.865625412,,E,4,4,4,4,4, | ||
Guayama,2.007035959,2.676466666,2.303109199,1.001763886,1.842086023,,E,4,4,4,4,4, | ||
Juana Díaz,1.495313851,2.783307624,2.705719034,0.749415362,1.781767806,,E,4,4,4,3,4, | ||
Maunabo,1.345485091,2.383261649,3.246594736,2.229535468,2.198329816,,E,4,4,4,4,4, | ||
Patillas,2.088023078,2.445459074,3.142223221,2.521004119,2.143654428,,E,4,4,4,4,4, | ||
Salinas,2.448692462,2.949356669,3.559179611,1.423991236,2.130137637,,E,4,4,4,4,4, | ||
Santa Isabel,2.280462423,2.87160131,2.387551908,0.916419673,1.936864593,,E,4,4,4,3,4, | ||
Arecibo,0.286740933,2.655937406,2.404610721,2.211990864,1.372617674,,W,2,4,4,4,4, | ||
Barceloneta,0.8998314,2.669975041,2.676618435,1.924654303,1.336523697,,W,3,4,4,4,4, | ||
Camuy,0.481244152,2.397261862,2.758679171,1.932025391,1.342485856,,W,2,4,4,4,4, | ||
Hatillo,1.323199715,2.629842907,2.565687479,1.522330924,1.242725798,,W,4,4,4,4,4, | ||
Isabela,0.475031438,2.497686039,3.279818168,2.35695378,1.355711868,,W,2,4,4,4,4, | ||
Quebradillas,1.611472616,2.529619137,3.279742835,2.718730311,1.647955129,,W,4,4,4,4,4, | ||
Aguada,2.253897585,2.216448813,2.997094838,1.472876679,1.320637194,,W,4,4,4,4,4, | ||
Aguadilla,1.165634534,2.543903698,2.931218395,2.185523442,1.722998388,,W,4,4,4,4,4, | ||
Añasco,-0.120184972,2.54771257,2.581492771,1.99255699,1.843040664,,W,1,4,4,4,4, | ||
Cabo Rojo,0.092670615,2.295622207,2.558504004,2.028908813,1.897814306,,W,2,4,4,4,4, | ||
Mayagüez,0.94225177,2.562330823,2.674249236,1.913921262,1.681279223,,W,3,4,4,4,4, | ||
Rincón,1.574400396,2.231397389,2.498315121,1.511248382,1.335953048,,W,4,4,4,4,4, | ||
Guánica,2.657434211,2.66456141,3.660103215,2.25910454,1.93110756,,W,4,4,4,4,4, | ||
Guayanilla,1.512389786,2.853064353,2.975665053,2.136359265,1.701346465,,W,4,4,4,4,4, | ||
Lajas,1.208963854,2.582513641,3.035750623,2.942650966,1.773471221,,W,4,4,4,4,4, | ||
Peñuelas,1.121795462,2.955265914,3.328214679,1.787965212,1.521441361,,W,4,4,4,4,4, | ||
Ponce,1.104599316,2.835514115,2.484125492,1.269653877,1.456800476,,W,4,4,4,4,4, |
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,59 @@ | ||
Community,PerDis,PopCom,Poverty,LabFrc_rev,HsChr_rev,RetMig,Region,PerDisCat,PopComCat,PovertyCat,LabFrc_revCat,HsChr_rev_Cat,RetMigCat | ||
Arecibo,0.305728367,0.614102657,0.33224115,0.672979872,0.934743325,0.52692041,W,2,3,2,3,3,3 | ||
Barceloneta,0.622220248,0.678304187,0.143657176,0.374450226,0.292813208,0.017561058,W,3,3,2,2,2,2 | ||
Camuy,-0.28536295,0.500933531,0.341732661,0.480228965,0.635634314,0.17553547,W,1,3,2,2,3,2 | ||
Hatillo,-1.15687254,0.514126626,0.457244484,0.157459027,0.716626045,-0.041424909,W,1,3,2,2,3,1 | ||
Isabela,0.132269661,0.485405445,0.853150776,0.61658239,0.646514635,0.081840593,W,2,2,3,3,3,2 | ||
Quebradillas,-0.183114325,0.42351042,0.494610526,0.702179079,0.598181875,0.585727878,W,1,2,2,3,3,3 | ||
Aguada,0.303267131,-0.028847843,0.345184455,0.892696401,0.717273712,0.624140837,W,2,1,2,3,3,3 | ||
Aguadilla,0.770145255,0.52113563,0.594440943,0.591866141,0.730782125,0.108823114,W,3,3,3,3,3,2 | ||
Añasco,1.646190184,0.150331875,0.100188863,0.619536886,0.732154148,0.833912681,W,4,2,2,3,3,3 | ||
Cabo Rojo,0.196745144,0.530134812,0.572828643,0.557020544,-0.809484919,0.613840384,W,2,3,3,3,1,3 | ||
Mayagüez,1.280810322,0.826622989,0.601586745,0.644397303,0.572081437,0.599690559,W,4,3,3,3,3,3 | ||
Rincón,0.026631906,0.078670023,0.126699821,0.398254812,0.295802968,0.762532274,W,2,2,2,2,2,3 | ||
Guánica,1.635011142,0.515457692,1.577783286,1.298511814,0.904612122,1.469358904,W,4,3,4,4,3,4 | ||
Guayanilla,1.057913972,0.590634757,1.422642534,0.420360286,0.909169783,0.071516738,W,4,3,4,2,3,2 | ||
Lajas,2.032435942,0.658990433,1.452226144,0.894563627,-0.15677397,1.43437425,W,4,3,4,3,1,4 | ||
Peñuelas,1.230498929,0.502566148,1.493060905,0.298641643,0.934369512,-0.423515296,W,4,3,4,2,3,1 | ||
Ponce,0.293433901,0.800812362,0.713810381,0.451249115,0.7915164,0.328511694,W,2,3,3,2,3,2 | ||
Carolina,-0.188908297,0.693062616,-0.723408399,-0.770299929,0.163738942,-0.297407164,E,1,3,1,1,2,1 | ||
Cataño,0.076387786,0.714312879,0.642749604,-0.055515684,0.372864195,-0.047891341,E,2,3,3,1,2,1 | ||
Dorado,0.064195672,0.094947202,-0.770709457,-0.308174511,-0.301156355,-0.6375253,E,2,2,1,1,1,1 | ||
Guaynabo,-1.52570582,0.305123232,-1.226510878,-0.747542203,-0.026950206,0.052962691,E,1,2,1,1,1,2 | ||
Loíza,1.966220124,1.030437114,0.755590528,-0.214834707,0.374761874,-0.269100449,E,4,4,3,1,2,1 | ||
Luquillo,0.279211283,0.519328706,-0.081611448,-0.129033475,0.218949701,0.005663429,E,2,3,1,1,2,2 | ||
Manatí,0.395334486,0.621139949,0.300598378,0.693367475,-0.051065156,0.440324958,E,2,3,2,3,1,2 | ||
Río Grande,0.585096726,0.404033954,-0.23529307,-0.380826534,0.082338837,-0.234116294,E,3,2,1,1,2,1 | ||
San Juan,-0.281829215,0.760998658,-0.215207836,-0.880388359,0.241579299,-0.845133894,E,1,3,1,1,2,1 | ||
Toa Baja,-0.130695767,0.458292575,-0.309465364,-0.533104891,0.192469974,-0.642237751,E,1,2,1,1,2,1 | ||
Vega Alta,0.558048846,0.136860713,0.275177174,0.047208288,0.292929722,-0.338746218,E,3,2,2,2,2,1 | ||
Vega Baja,0.32113084,0.254080204,0.265498483,0.340927205,0.111259033,0.202126882,E,2,2,2,2,2,2 | ||
Ceiba,0.464554217,0.373813171,-0.092749482,0.510164216,0.059134181,0.826269544,E,2,2,1,3,2,3 | ||
Culebra,-1.455668471,-0.019689732,-0.64965152,-0.964797966,-1.011852185,0.745922776,E,1,1,1,1,1,3 | ||
Fajardo,1.174047428,0.788558064,0.178609453,-0.326598279,0.356786479,-0.193949428,E,4,3,2,1,2,1 | ||
Humacao,-0.266861698,0.466078772,-0.323717693,0.814101299,0.191410939,0.717309915,E,1,2,1,3,2,3 | ||
Naguabo,0.584907738,0.469651131,0.082681383,0.725545284,0.252946499,-0.311708566,E,3,2,2,3,2,1 | ||
Vieques,-0.659338497,0.574684329,1.095174057,1.072061785,-0.277870695,1.83679604,E,1,3,4,4,1,4 | ||
Yabucoa,0.804246568,0.546836199,0.773225949,0.995580526,0.465369795,1.078255186,E,3,3,3,3,2,4 | ||
Arroyo,0.503976951,0.905332339,1.405066265,1.06346106,0.677892986,0.766085698,E,3,3,4,4,3,3 | ||
Guayama,0.133951071,0.824026375,1.045935995,0.910186396,0.649651787,0.45042042,E,2,3,4,3,3,2 | ||
Juana Díaz,0.945177839,0.356638516,0.258646083,-0.076313064,0.703669615,-0.453775423,E,3,2,2,1,3,1 | ||
Maunabo,-0.191736672,0.668119857,-0.334931483,1.414150024,0.500432279,1.75302307,E,1,3,1,4,3,4 | ||
Patillas,-0.124546019,0.352441142,0.422209381,1.106169179,0.512484533,0.982694834,E,1,2,2,4,3,3 | ||
Salinas,0.140280141,0.532565864,0.553200353,0.563659099,0.622379116,0.415814656,E,2,3,3,3,3,2 | ||
Santa Isabel,0.323163606,0.570852253,0.450885258,-0.406819462,0.358861133,-0.738367861,E,2,3,2,1,2,1 | ||
Anna's Hope Village,-2.159246796,-1.748902471,-2.05224105,-1.358692475,-0.975771939,-0.664215237,STX,1,1,1,1,1,1 | ||
Christiansted,-0.834611761,-1.3348867,-0.499624649,-1.630789504,-1.090519954,-2.21274314,STX,1,1,1,1,1,1 | ||
East End,-2.9277645,-2.644842985,-2.621171397,-1.13083454,-2.039241251,0.098620945,STX,1,1,1,1,1,2 | ||
Frederiksted,1.411376115,-1.390037584,0.196662378,-1.295651803,-0.465219774,-2.194265212,STX,4,1,2,1,1,1 | ||
Northcentral,-0.335247188,-1.380412271,-1.144580742,-0.684011094,-1.301032228,0.238908382,STX,1,1,1,1,1,2 | ||
Sion Farm,-1.139952289,-1.609707609,-1.583632478,-1.296336285,-1.547054638,-0.726315924,STX,1,1,1,1,1,1 | ||
Southcentral,0.150377611,-1.488909375,-0.579118436,-1.275740971,-0.600592407,-1.36939953,STX,2,1,1,1,1,1 | ||
Southwest,-0.365113745,-1.371992386,-1.124611499,-0.805104622,-0.492336003,-0.392407932,STX,1,1,1,1,1,1 | ||
Central,-1.980763798,-2.522347303,-2.609342278,-2.697694566,-3.475443832,-2.859407608,STJ,1,1,1,1,1,1 | ||
Coral Bay,-1.733411855,-2.651853432,-2.017530695,-2.039727366,-2.342665831,-1.249384704,STJ,1,1,1,1,1,1 | ||
Charlotte Amalie,0.366990126,-1.123428319,-1.009363716,-1.695029557,-1.860349904,-1.91337523,STT,2,1,1,1,1,1 | ||
East End,-0.533541674,-1.591452619,-1.679186043,-2.188236701,-2.022293754,-2.341074655,STT,1,1,1,1,1,1 | ||
Northside,-2.083409361,-1.872281518,-2.115453266,-2.160687522,-2.595421029,-1.493931598,STT,1,1,1,1,1,1 | ||
Tutu,-0.974100426,-1.133059864,-1.708570058,-1.021285931,-0.998198083,0.207045657,STT,1,1,1,1,1,2 | ||
West End,-2.389627969,-1.649412426,-2.61161284,-2.040500828,-1.768735535,-0.549642693,STT,1,1,1,1,1,1 |
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.
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.
166 changes: 166 additions & 0 deletions
166
indicator_processing/non_automated/social_vulnerability.R
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,166 @@ | ||
# Code to plot social vulnerability data for PR and USVI. Eventually, the data will be added to NOAA's social vulnerability indicators tool (https://www.st.nmfs.noaa.gov/data-and-tools/social-indicators/). But for now, we are using data emailed by Tarsila Seara on 4/10/24. | ||
|
||
# Last updated 6/14/2024 by Carissa Gervasi | ||
|
||
# For the commercial fishing engagement and reliance indicators we are using maps that were previously generated. | ||
|
||
# The remaining indicators that will be plotted here are the environmental justice, economic, and gentrification pressure indicators. | ||
|
||
# Load the data | ||
|
||
library(readr) | ||
CSVI_2010 = read_csv("indicator_data/CaribCSVI_2010.csv", locale = locale(encoding = "UTF-8")) | ||
CSVI_2020 = read_csv("indicator_data/CaribCSVI_2020.csv", locale = locale(encoding = "UTF-8")) | ||
|
||
|
||
library(ggplot2) | ||
library(dplyr) | ||
library(tidyr) | ||
|
||
CSVI_2010$Year <- 2010 | ||
CSVI_2020$Year <- 2020 | ||
|
||
|
||
# Combine both dataframes | ||
df_combined <- bind_rows(CSVI_2010, CSVI_2020) | ||
|
||
#remove columns for raw data | ||
df_combined = df_combined[,-c(2:7)] | ||
|
||
|
||
# Convert to long format for ggplot | ||
df_long <- df_combined %>% | ||
pivot_longer(cols = ends_with("Cat"), | ||
names_to = "Indicator", | ||
values_to = "Score") | ||
|
||
# Remove rows with NA values | ||
df_long <- na.omit(df_long) | ||
|
||
df_long$Community = as.character(df_long$Community) | ||
df_long$Region = as.character(df_long$Region) | ||
df_long$Year = as.factor(df_long$Year) | ||
df_long$Indicator = as.character(df_long$Indicator) | ||
df_long$Score = as.integer(df_long$Score) | ||
|
||
|
||
|
||
# Rename and combine regions | ||
df_long <- df_long %>% | ||
mutate(Region = recode(Region, | ||
'STT' = 'St. Thomas & St. John', | ||
'STJ' = 'St. Thomas & St. John', | ||
'STX' = 'St. Croix', | ||
'W' = 'Puerto Rico West', | ||
'E' = 'Puerto Rico East')) | ||
|
||
# Verify the changes | ||
unique(df_long$Region) | ||
|
||
|
||
# Rename indicators | ||
df_long <- df_long %>% | ||
mutate(Indicator = recode(Indicator, | ||
'PerDisCat' = 'Personal Disruption', | ||
'PopComCat' = 'Pop Composition', | ||
'PovertyCat' = 'Poverty', | ||
'LabFrc_revCat' = 'Labor Force', | ||
'HsChr_rev_Cat' = 'Housing Charac', | ||
'RetMigCat' = 'Retiree Migration')) | ||
|
||
unique(df_long$Indicator) | ||
|
||
|
||
# Create Faceted Bar Plots for each region | ||
regions <- unique(df_long$Region) | ||
|
||
for (region in regions) { | ||
p <- ggplot(df_long %>% filter(Region == region), aes(x = Community, y = Score, fill = as.factor(Year))) + | ||
geom_bar(stat = "identity", position = "dodge") + | ||
facet_wrap(~ Indicator, scales = "free_y") + | ||
theme_bw() + | ||
theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 5), | ||
axis.text.y = element_text(size = 10), | ||
strip.text = element_text(size = 10), | ||
legend.title = element_text(size = 10), | ||
legend.text = element_text(size = 10)) + | ||
labs(title = paste("Standardized Indicator Scores by Community & Year", region), | ||
x = "Community", | ||
y = "Score", | ||
fill = "Year") | ||
|
||
ggsave(paste0("indicator_plots/CSVI_plots/Faceted_Bar_Plot_", region, ".png"), plot = p, width = 12, height = 8) | ||
} | ||
|
||
|
||
|
||
# Create Line Plots for each region | ||
for (region in regions) { | ||
p <- ggplot(df_long %>% filter(Region == region), aes(x = Year, y = Score, color = Community, group = Community)) + | ||
geom_line() + | ||
geom_point() + | ||
facet_wrap(~ Indicator, scales = "free_y") + | ||
theme_bw() + | ||
theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 10), | ||
axis.text.y = element_text(size = 10), | ||
strip.text = element_text(size = 10), | ||
legend.title = element_text(size = 10), | ||
legend.text = element_text(size = 10)) + | ||
labs(title = paste("Change in Standardized Indicator Scores Over Time by Community", region), | ||
x = "Year", | ||
y = "Score", | ||
color = "Community") | ||
|
||
ggsave(paste0("indicator_plots/CSVI_plots/Line_Plot_", region, ".png"), plot = p, width = 12, height = 8) | ||
} | ||
|
||
|
||
|
||
|
||
# Create Heatmaps for each region | ||
for (region in regions) { | ||
p <- ggplot(df_long %>% filter(Region == region), aes(x = as.factor(Year), y = Community, fill = Score)) + | ||
geom_tile() + | ||
facet_wrap(~ Indicator, scales = "free_y") + | ||
scale_fill_gradient(low = "blue", high = "red") + | ||
theme_minimal() + | ||
theme(panel.background = element_rect(fill = "white", color = NA), | ||
plot.background = element_rect(fill = "white", color = NA), | ||
axis.text.x = element_text(angle = 45, hjust = 1, size = 10), | ||
axis.text.y = element_text(size = 10), | ||
strip.text = element_text(size = 10), | ||
legend.title = element_text(size = 10), | ||
legend.text = element_text(size = 10)) + | ||
labs(title = paste("Heatmap of Standardized Indicator Scores by Community and Year", region), | ||
x = "Year", | ||
y = "Community", | ||
fill = "Score") | ||
|
||
ggsave(paste0("indicator_plots/CSVI_plots/Heatmap_", region, ".png"), plot = p, width = 12, height = 8, bg = "white") | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
# Create Box Plots for each region | ||
for (region in regions) { | ||
p <- ggplot(df_long %>% filter(Region == region), aes(x = as.factor(Year), y = Score, fill = as.factor(Year))) + | ||
geom_boxplot() + | ||
facet_wrap(~ Indicator, scales = "free_y") + | ||
theme_bw() + | ||
theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 10), | ||
axis.text.y = element_text(size = 10), | ||
strip.text = element_text(size = 10), | ||
legend.title = element_text(size = 10), | ||
legend.text = element_text(size = 10)) + | ||
labs(title = paste("Distribution of Standardized Indicator Scores by Year", region), | ||
x = "Year", | ||
y = "Score", | ||
fill = "Year") | ||
|
||
ggsave(paste0("indicator_plots/CSVI_plots/Box_Plot_", region, ".png"), plot = p, width = 12, height = 8) | ||
} | ||
|
||
|