diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b6a065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/lab2-visualization.Rproj b/lab2-visualization.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/lab2-visualization.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/lab2.Rmd b/lab2.Rmd index c4df28f..1ba3663 100644 --- a/lab2.Rmd +++ b/lab2.Rmd @@ -1,10 +1,12 @@ --- title: "lab2" -author: "Gavin Martinez, Brandon Kim" +author: "Gavin Martinez, Brandon Kim, Shreya Ravilla" date: "2023-04-13" output: html_document --- +## Part 1 + **1. While there are certainly issues with this image, do your best to tell the story of this graph in words. That is, what is this graph telling you? What do you think the authors meant to convey with it?** The graph seems to show a plot of proportions of people who believe vaccines are safe per country. And each the plot seems to be separated by region, with certain countries being labeled. For each plot, there is a line within the plots, showing the median per each region. @@ -37,6 +39,7 @@ knitr::opts_chunk$set(warning = FALSE, message = FALSE) library(tidyverse) library(readxl) library(ggthemes) +library(plotly) ``` ```{r readxl} @@ -80,3 +83,60 @@ ggplot(plt, aes(x = prop, y = region, fill = region)) + theme(legend.position = "none") ``` +## Part 2 + +Trust in medical and health advice from government or doctors and nurses by region; p. 72 +```{r} +med <- tibble(country = toupper(c("World", "Eastern Africa", "Central Africa", "North Africa", "Southern Africa", "Western Africa", "Central America & Mexico", "Northern America", "South America", "Central Asia", "East Asia", "Southeast Asia", "South Asia", "Middle East", "Eastern Europe", "Northern Europe", "Southern Europe", "Western Europe", "Austrailia & New Zealand")), + med_workers = c(.84, .83, .57, .79, .69, .78, .8, .92, .74, .88, .82, .84, .87, .82, .81, .93, .91, .95, .97), + gov = c(.76, .82, .53, .73, .64, .71, .74, .61, .66, .86, .77, .79, .84, .73, .53, .77, .65, .78, .86)) + +``` + +```{r} +med <- med |> + mutate(med_workers = med_workers * 100, + gov = gov * 100) + +head(med) +``` + + +```{r} +med2 <- df_world %>% + filter(Q21 == 1 | Q21 == 2, + Q22 == 1 | Q22 == 2) %>% + group_by(WP5) %>% + summarize(gov = sum(Q21 %in% c(1, 2)), + med_workers = sum(Q22 %in% c(1, 2)), + Regions_Report) + +``` + +```{r} +#https://plotly.com/r/bar-charts/ +med$country <- factor(med$country, levels = med[["country"]]) + +fig <- plot_ly(med, + x = ~country, + y = ~med_workers, + type = 'bar', + name = 'Medical Workers', + marker = list(color = "steelblue")) + +fig <- fig |> + add_trace(y = ~gov, + name = 'Government', + marker = list(color = "orange")) + +fig <- fig |> layout(title = "Trust in Medical and Health Advice from Government or Doctors and Nurses by Region", + xaxis = list(title = "Region", + tickangle = -45), + yaxis = list(title = "Percentage"), + margin = list(b = 100), + barmode = 'group') + +fig +``` + + diff --git a/~$wgm2018-dataset-crosstabs-all-countries.xlsx b/~$wgm2018-dataset-crosstabs-all-countries.xlsx new file mode 100644 index 0000000..5a93205 Binary files /dev/null and b/~$wgm2018-dataset-crosstabs-all-countries.xlsx differ