r percentage by bin in histogram ggplot
问题 I have a data set like this -> library(ggplot2) response <- c("Yes","No") gend <- c("Female","Male") purchase <- sample(response, 20, replace = TRUE) gender <- sample(gend, 20, replace = TRUE) df <- as.data.frame(purchase) df <- cbind(df,gender) so head(df) looks like this -> purchase gender 1 Yes Female 2 No Male 3 No Female 4 No Female 5 Yes Female 6 No Female Also, so you can validate my examples, here is table(df) for my particular sampling. (please don't worry about matching my