From a8151c0271c98f6157bc4a1171cd99fb7db3a6e3 Mon Sep 17 00:00:00 2001 From: Shreya Ravilla Date: Mon, 17 Apr 2023 22:40:36 -0700 Subject: [PATCH] plotly --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 4 ++ lab2-visualization.Rproj | 13 ++++ lab2.Rmd | 62 +++++++++++++++++- ...m2018-dataset-crosstabs-all-countries.xlsx | Bin 0 -> 165 bytes 5 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 lab2-visualization.Rproj create mode 100644 ~$wgm2018-dataset-crosstabs-all-countries.xlsx diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 + 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 0000000000000000000000000000000000000000..5a932052db2a5d1e1d32a453f59be330b8becc3b GIT binary patch literal 165 zcmWgj%}g%JFV0UZQSeVo%S=vH2rW)6QXm9G8GIQs8Il=_81fm4fjEt!gh7G9A4sQx R#Z!U2P@qgIP=x};5CA3W7%cz* literal 0 HcmV?d00001