I guess I am trying to create a geom_line version of a geom_bar. The reason I want to do lines is because when I enter
geom_bar(aes(fill = Decile), position = position_dodge())
I am stuck with ten segments and my bar chart looks extremely cluttered.
I have 11 separate x variables going across the bottom.
The problem is I dont know how to use the count as a "y" variable and have tried things like ..count..
and other approached but am completely lost. Any ideas?
Thanks for the help!
My data looks like this:
Name Decile Division
Joe 1 San Diego
Jan 1 New York
Jay 2 San Diego
Lue 3 Dallas
Suz 2 Seattle
tye 3 Dallas
MCD <- read.csv("Decile15.csv", header = TRUE)
MCD$MonthNo <- factor(MCD$MonthNo, levels = c(1:11), labels = c("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November"))
Decile_names <- c('1' = "Decile #1",
'2' = "Decile #2",
'3' = "Decile #3",
'4' = "Decile #4",
'5' = "Decile #5"
)
MCDGraph <- ggplot(na.omit(MCD), aes(MonthNo))
MCDGraph + geom_bar(aes(fill = Division), color = "black", position = "fill") + facet_wrap(~Decile, nrow = 1, labeller = labeller(Decile = as_labeller(Decile_names))) + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) + scale_fill_manual(values = c("#DA4424", "#24A0DA", "#F0BC0B", "#43F749", "#4348F7", "#F74369", "#D7B9F5")) + theme(panel.background = element_rect(colour = "black", fill = "white"), panel.grid.minor = element_line(color = "black", size = .5)) + labs(x = "2017", y = "% of Leads Per Month By Division") + scale_y_continuous(labels = percent_format()) + theme(strip.background = element_blank(), strip.text = element_text(size = 25))
This is what my % of grouped facet_wrap bar chart looked like.
I split those into 5 so that I could see five plots instead of 10 on one pdf sheet. Also this is only divided into the 7 total divisions. I want to do one that is divided into 10. Here is an example I used to make my grouped regular without faceting anything.
MC <- read.csv("2017_Full_year.csv", header = TRUE)
MC$MonthNo <- factor(MC$MonthNo, levels = c(1:11), labels = c("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November"))
MCH <- ggplot(na.omit(MC), aes(MonthNo))
MCH + geom_bar(aes(fill = Division), position = position_dodge() ) + labs(x = "2017", y = "# of Leads") + theme(axis.line = element_line(color = "black", size = 3, linetype = "solid"), axis.text.x = element_text(face = "bold", color = "black", size = 14),
axis.text.y = element_text(face = "bold", color = "black", size = 14)) + scale_y_continuous(name = "# Of Leads", breaks = seq(0,1000, 50)) + theme(panel.background = element_rect(colour = "black",
fill = "white"), panel.grid.minor = element_line(color = "black", size = .5), panel.grid.major = element_line(color = "black", size = .5)) +
scale_fill_manual(values = c("#DA4424", "#24A0DA", "#F0BC0B", "#43F749", "#4348F7", "#F74369","#D7B9F5"))
EDIT: Or should I just create a new csv with the the final counts for each Decile during each month already in it. This would be a quick fix and I can pull the numbers very easily from SQL server. I was just hoping to do this without having to create a new file.