I'm trying to visualize a cross-tabulation on RStudio using ggplot2. I've been able to create plots in the past, and have a cross-tabulation done as well, but can't crack this. Can anyone help?
Here's my code for an x-tab:
library(dplyr)
data_dan %>%
  group_by(Sex, Segment) %>%
  count(variant) %>%
  mutate(prop = prop.table(n))
and here's what I've got for creating a plot:
#doing a plot
variance_art_new.plot = ggplot(data_dan,  aes(Segment, fill=variant)) +
  geom_bar(position="fill")+
  theme_classic()+
  scale_fill_manual(values = c("#fc8d59", "#ffffbf", "#99d594"))
variance_art_new.plot
Here's a sample of the data I'm operating with:
   Word  Segment  variant  Position     Sex
1  LIKE       K       R       End      Female
2  LITE       T       S       End      Male
3 CRACK       K       R       End      Female
4  LIKE       K       R       End      Male
5  LIPE       P       G       End      Female
6  WALK       K       G       End      Female
My aim is to have the independent variables of 'Sex', 'Segment' plotted on a boxplot against the dependent variable 'variant'. I included the first code to show that I can create a table to show this cross-tabulation and the second bit is what I normally do for running a box plot for just one independent variable.
 
    


