R Visualization Assignment 1

Author

McCloud Amir

Note to Manager

As requested for the meeting I created a rudimentary visualization to show how we plan to handle the Urban Institute’s Well-Being and Basic Needs Survey project. The request analysis was a focus on the relationship between the respondents level of health (Variable: Q27) and their Allowance for leave in their primary place of employment. The data was cleaned up slightly to remove the NA which could be contextualized if needed but detracted from the clarity of the visualization. A gradient was also introduced based on the weighting internally created in the data frame and a facet made to juxtapose the outcomes of respondents with more than one job. Which does a good job of illustrating that there are other confounding variables that need to be addressed to show that the hypothesis surrounding the relationship between leave policy and health outcomes exists.

library(ggplot2)
library(ggcorrplot)
Warning: package 'ggcorrplot' was built under R version 4.4.1
library(tidyverse)
Warning: package 'stringr' was built under R version 4.4.1
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ lubridate 1.9.3     ✔ tibble    3.2.1
✔ purrr     1.0.2     ✔ tidyr     1.3.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(grid)
library(prettyR)
load("~/Working Directory/Visualization/da38759.0001.rda")

One <- da38759.0001
One <-  One %>% filter(as.integer(Q27) %in%  c(1:5))
One <-  One %>% filter(as.integer(Q39) %in%  1:2)
p <- ggplot(One, aes(x = Q27, y = Q48A_1, fill = WEIGHT)) +
  geom_tile(color = "white",
            lwd = 1.5,
            linetype = 1) +
            scale_fill_gradient(low = "red", high = "green") +
            facet_grid(~Q39) 

print(p + labs(title = "Paid Leave Policy", subtitle = "Plot of the relationship between Leave Allowance and Health",y = "Allowance for Leave", x = "Level of Health", fill = "Weight", caption = "Based on Well-Being and Basic Needs Survey ") +  theme(plot.caption = element_text(size=16, color="red", face="italic")))