Suppose I have the following two data sets:
behaviorm <- structure(list(sentential_connective = c("IF", "IF", "IF", "IF",
"IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF",
"IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF",
"IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF", "IF",
"IF", "IF", "IF"), mentioned_object = c("Same", "Same", "Same",
"Same", "Same", "Same", "Same", "Same", "Same", "Same", "Same",
"Same", "Same", "Same", "Same", "Same", "Same", "Same", "Same",
"Same", "Same", "Same", "Same", "Same", "Same", "Same", "Same",
"Same", "Same", "Same", "Same", "Same", "Same", "Same", "Same",
"Same", "Same", "Same", "Same", "Same"), agent_mood = c("Sad",
"Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad",
"Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad",
"Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad",
"Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad", "Sad",
"Sad", "Sad", "Sad"), Chosen_Box = c("SD", "SD", "SD", "SD",
"SD", "SD", "SD", "SD", "SD", "SD", "CS", "CS", "CS", "CS", "CS",
"CS", "CS", "CS", "CS", "CS", "SS", "SS", "SS", "SS", "SS", "SS",
"SS", "SS", "SS", "SS", "DD", "DD", "DD", "DD", "DD", "DD", "DD",
"DD", "DD", "DD"), participant = c("a01", "a02", "a03", "a04",
"a05", "a06", "a07", "a08", "a09", "a10", "a01", "a02", "a03",
"a04", "a05", "a06", "a07", "a08", "a09", "a10", "a01", "a02",
"a03", "a04", "a05", "a06", "a07", "a08", "a09", "a10", "a01",
"a02", "a03", "a04", "a05", "a06", "a07", "a08", "a09", "a10"
), Counts = c(12L, 8L, 12L, 6L, 3L, 12L, 9L, 12L, 12L, 11L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 0L, 0L, 0L, 4L, 0L, 4L, 9L, 0L, 2L, 0L, 0L, 0L)), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 73L, 74L, 75L, 76L, 77L,
78L, 79L, 80L, 81L, 82L, 145L, 146L, 147L, 148L, 149L, 150L,
151L, 152L, 153L, 154L, 217L, 218L, 219L, 220L, 221L, 222L, 223L,
224L, 225L, 226L), class = "data.frame")
res <- structure(list(sentential_connective = c("IF", "IF", "IF", "IF"
), mentioned_object = c("Same", "Same", "Same", "Same"), agent_mood = c("Sad",
"Sad", "Sad", "Sad"), Chosen_Box = c("SD", "CS", "SS", "DD"),
statistic = c(54, 0, 0, 8), p.value = c(0.00362357852661936,
0.999052845531107, 0.999052845531107, 0.937942586194492),
Sig = c("*", "", "", ""), Counts = c(12L, 1L, 1L, 9L)), class = "data.frame", row.names = c(1L,
73L, 145L, 217L))
And the following code I used to do the plotting:
library(ggplot2)
b <- ggplot()
b <- b + aes(x = sentential_connective, y = Counts)
b <- b + geom_boxplot(aes(color = Chosen_Box), data = behaviorm, outlier.color = NA)
b <- b + geom_text( aes(label = Sig), data = res, position = position_dodge2(width = 0.9), size = 5)
b
In the resulting graph, however, the label from the res
file is not correctly aligned with the boxplot from the behaviorm
file.
I've tried the suggestions explained in the explanation and did not succeed.
Any suggestions? Thanks.