Hi @christinelly,
So it looks like you're taking tidy data (one variable per column, in this case, sleep_cleaned$sex) and ~ untidying it when you put the pieces back together (rather than having a data frame with sex, genhlth, sleep_median, and ratio, you have the median and ratio variables given twice, one for women and one for men).
What I think you want to be doing is grouping by multiple variables (the link below is to R4DS 5.6.5 Grouping by multiple variables):
Once you do that, you'll be able to do the kind of grouped bar chart you're describing (you can look at the code in the R graph gallery):
You can also see the Position adjustment section of R4DS, which describes how ggplot2 maps the variables to the aesthetics to make the grouping.