location="https://github.com/pubpolicy/PubPolicy-543/raw/main/"
file="gbdChildMortality_Modified_2010s.csv"
linkToFile=paste0(location,file)
gdb=read.csv(linkToFile)
head(gdb)
## gbdRegion neoMR postneoMR age1_5MR under5MR
## 1 Asia, South 56.03 35.76 34.66 121.33
## 2 Sub-Saharan Africa, Central 37.33 47.03 56.93 134.83
## 3 Europe, Central 3.66 8.31 3.24 15.14
## 4 Europe, Western 2.98 1.42 0.46 4.86
## 5 North Africa / Middle East 2.40 0.50 0.09 2.98
## 6 Latin America, Southern 8.17 3.81 0.95 12.88
library(reshape2)
gdbL=melt(gdb, # all the data
id.vars = 'gbdRegion') # unique id per row
head(gdbL)
## gbdRegion variable value
## 1 Asia, South neoMR 56.03
## 2 Sub-Saharan Africa, Central neoMR 37.33
## 3 Europe, Central neoMR 3.66
## 4 Europe, Western neoMR 2.98
## 5 North Africa / Middle East neoMR 2.40
## 6 Latin America, Southern neoMR 8.17
library(ggplot2)
base = ggplot(data = gdbL, aes(x = variable,
y =gbdRegion))
heat1= base + geom_tile(aes(fill = value))
heat1
#inverse color -1
heat2 = heat1 + scale_fill_gradient(low = 'grey',
high = "black")
heat2
# change in REORDER
base= ggplot(data = gdbL, aes(x = reorder(variable,
value, median),
y =reorder(gbdRegion,
value, median)))
# THIS IS THE SAME
base + geom_tile(aes(fill = value)) +
scale_fill_gradient(low = 'grey90',high = "grey50") +
theme(axis.text.x = element_text(angle = 0, hjust = 1,size = 10),
axis.text.y = element_text(size = 9))
####```{r} base = ggplot(gdbL, aes(x = variable, y = gbdRegion, group = )) + #new geom_polygon(fill = ‘gray’, col=‘orange’)
plot1 = base + coord_polar()
plot2 = plot1 + facet_wrap(~gbdRegion,# one plot per city ncol = 4) # ten plot per row plot2
##```{r}
plot2 = plot1 + facet_wrap(~reorder(gbdRegion,value, median, order=TRUE),ncol = 4)
plot3 = plot2 + theme(axis.text.x = element_text(size = 2))
plot3
plot4 = plot3 + theme(legend.position="none",
strip.text = element_text(size = 10)) #here!!!
plot4
### arguments
newBackGroundGrid=element_rect(fill = "white",
colour = "red",
size = 0.5,
linetype = "dashed")
newBackLineGrid=element_line(size = 1,
linetype = 'solid',
colour = "lightblue")
### more customization
plot4+ theme(panel.background = newBackGroundGrid,
panel.grid.major = newBackLineGrid)###