Home > OS >  Frequency plot for different categories
Frequency plot for different categories

Time:03-02

I have this input:

structure(list(Topic = structure(c(1L, 2L, 3L, 1L, 2L, 3L), .Label = c("1", 
"2", "3"), class = "factor"), Sex = structure(c(1L, 1L, 1L, 2L, 
2L, 2L), .Label = c("Female", "Male"), class = "factor"), Count = c(2L, 
15L, 23L, 7L, 20L, 34L)), class = "data.frame", row.names = c(NA, 
-6L))

and I try this code:

ggplot(data=dat, aes(x=Topic, y=Sex, fill=Sex))   geom_bar(stat="identity")

However the problem is it shows the same proposion for every topic

How is it possible to make the plot like enter image description here

  • Related