my code about drawing bar chart is here
library(ggplot2)
fig_num <- ggplot(data=branch.fig, aes(y=branch.fig$num, x=branch.fig$film.type, fill = branch.fig$film.type)) +
geom_bar(position=position_dodge(), stat="identity", width = 0.3, colour = "gray35") +
scale_fill_manual(values = colors) +
facet_grid(branch.type~.) +
geom_errorbar(aes(ymin=branch.fig$num, ymax=branch.fig$num +branch.fig$SE), position="dodge", width=0.1, col = "gray40") +
theme(legend.position = "none", plot.title = element_text(hjust = 0.5)) +
labs(x = "Film Type",y = "Branch Number") +
ggtitle("DAS = 54") + coord_flip()
fig_num
The result I want to have should be like this,
but what I get is like this, the R combine part of the data, I don't know why would appear this, it's really a big problem for me to solve, sincerely looking for your help,thanks a lot!
following is dataset
dput(subset(branch.fig))
structure(list(film.type = structure(c(1L, 1L, 2L, 2L, 3L, 3L,
4L, 4L, 5L, 5L, 6L, 6L), .Label = c("black", "ck", "dark-gray",
"green", "red", "white"), class = "factor"), branch.type = structure(c(1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("F",
"V"), class = "factor"), num = c(14.6666666666667, 3.33333333333333,
14, 2.66666666666667, 15.3333333333333, 2, 14.6666666666667,
2.66666666666667, 16.6666666666667, 3.33333333333333, 20.3333333333333,
1.66666666666667), SE = c(0.333333333333333, 0.333333333333333,
1.15470053837925, 0.333333333333333, 0.881917103688197, 0, 0.881917103688197,
0.666666666666667, 0.333333333333333, 0.666666666666667, 2.33333333333333,
0.666666666666667), n = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L)), .Names = c("film.type", "branch.type", "num", "SE",
"n"), row.names = c(NA, -12L), class = c("grouped_df", "tbl_df",
"tbl", "data.frame"), vars = list(film.type), drop = TRUE, indices = list(
0:1, 2:3, 4:5, 6:7, 8:9, 10:11), group_sizes = c(2L, 2L,
2L, 2L, 2L, 2L), biggest_group_size = 2L, labels = structure(list(
film.type = structure(1:6, .Label = c("black", "ck", "dark-gray",
"green", "red", "white"), class = "factor")), row.names = c(NA,
-6L), class = "data.frame", vars = list(film.type), drop = TRUE, .Names =
"film.type"))