I am trying to see relationships between Happiness and a multitude of other variables, for example, AGE or SEX or MARITAL STATUS, using ggplot(). I have this data set
https://xdaiisu.github.io/ds202materials/hwlabs/HAPPY.rds
library(ggplot2)
HAPPY[HAPPY == "IAP"] <- NA
HAPPY[HAPPY == "DK"] <- NA
HAPPY[HAPPY == "NA"] <- NA
I downloaded this data set, and I converted some of the variables to 'factors' using this code, I will just use MARITAL and HAPPY as an example;
HAPPY <- HAPPY %>% mutate(MARITAL = factor(MARITAL,
levels = c("NEVER MARRIED", "MARRIED", "SEPARATED", "DIVORCED", "WIDOWED")))
%>% arrange(desc(MARITAL))
HAPPY <- HAPPY %>% mutate(HAPPY= factor(HAPPY,
levels = c("NOT TOO HAPPY", "PRETTY HAPPY", "VERY HAPPY")))
%>% arrange(desc(HAPPY))
Now I want to use a ggplot2 graph to show the relationship between MARITAL and Happiness(denoted by the column HAPPY). I am relatively new to ggplot2, so I am just trying to figure out ways to use it. Also, if you don't want to do HAPPY VS MARITAL then you can use any variable or column to compare to HAPPY as well that you would like I just keep getting errors.
Thanks!
dplyrpackage to group your data and find counts of occurrences of the permutations of Marital and Happy columns. iedf %>% group_by(MARITAL, HAPPY) %>% summarise (Count = n())