Я пытаюсь добавить панели ошибок в график, который я создал: ![enter image description here](https://i.stack.imgur.com/QWeqZ.png)
Как видите, панели ошибок не в нужном месте, и я не могу понятьпочему нет.Ниже приведен код, который я использовал:
df_midtermclean$gender <- factor(df_midtermclean$ï..gender, labels = c('Male', 'Female'))
#reshaping from wide to long format
data_long <- melt(df_midtermclean,
# ID variables - all the variables to keep but not split apart on
id.vars=c("gender"),
# The source columns
measure.vars=c("sSkills", "sPerform", "sComplex", "sIQ" ),
# Name of the destination column that will identify the original
# column that the measurement came from
variable.name="measures",
value.name="score")
p2 <- ggplot(data_long, aes(measures, score)) + stat_summary(fun.y = mean, geom = "bar", aes(fill = gender), position = "dodge")
p2 <- p2 + stat_summary(geom = "errorbar", fun.data = mean_cl_normal, position = position_dodge(.9), width = .1)
p2 <- p2 + labs(x = "Continuous Measures", y = "Participant Scores", fill = "Gender")
p2
Данные.
data_long <-
structure(list(gender = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
2L, 2L, 1L, 1L, 1L), .Label = c("Male", "Female"),
class = "factor"), measures = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L), .Label = c("sSkills",
"sPerform", "sComplex", "sIQ"), class = "factor"),
score = c(4.75, 3, 3.5, 3.75, 3, 3.25, 3.25, 3,
2.75, 2.75, 2.5, 2.75, 3.75, 3.5, 3.75, 3.75,
3.25, 3.25, 4, 3.25)), row.names = c(NA, 20L),
class = "data.frame")