meinen Code über Balkendiagramm Zeichnung ist hierProbleme in Zeichnen Sie ein Balkendiagramm mit ggplot2 unter Verwendung facet_grid Funktion
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
Das Ergebnis sollte ich so sein zu wollen,
aber was ich bekomme ist so, die R kombinieren einen Teil der Daten, ich weiß nicht, warum das so erscheinen würde, es ist wirklich ein großes Problem für mich zu lösen, aufrichtig auf der Suche nach deiner Hilfe, vielen Dank!
finden 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"))
Bitte geben Sie Ihre Daten in einer [reproduzierbaren Form] an (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Verknüpfen Sie keinen Screenshot Ihrer Daten, da andere dazu gezwungen werden müssten, diese zu transkribieren, bevor Sie mit Ihrem Problem helfen. –
Vielen Dank für Ihre Erinnerung, ich habe meine Frage bearbeitet, um das Dataset darin zu kopieren ~ –
Leider funktioniert die 'dput' Ausgabe nicht richtig, weil' dplyr' und 'dput' nicht ganz zurechtkommen. Versuchen Sie, die Ausgabe von 'dput (ungroup (branch.fig))' (von dieser Frage http://stackoverflow.com/questions/29039553/reproducible-example-and-dput-error) – bdemarest