I am trying to run the following code:
temp_plotdata <- data.table(Treatment_Code = c('Control', 'Control',
'Second Mailing', 'Second Mailing',
'First Mailing', 'First Mailing'),
Q9 = c(9, 14, 10, 3, 1, 4))
output_gg <-
ggplot(temp_plotdata, aes(x = Q9)) +
geom_histogram(binwidth = 1, fill = 'lightblue') +
geom_vline(data = temp_plotdata[, summary(Q9)[c(2,3,5)], by=Treatment_Code],
aes(xintercept = V1),
linetype = 'dashed', color = 'darkred') +
facet_wrap(~Treatment_Code, ncol = 1)
I am returning an error:
Error in allowDimnames (x, sep = sep, base = base) parameters: "dimnames" applies to a non-array
I know that the problem is part of the code geom_vline, because when I run it without these lines or run it with something like geom_vline(xintercept = c(3, 5, 8)), it works fine. I also tried first converting the data from geom_vlineto a separate data framework, but that didn't work.
Last year I used a very similar code, and it worked fine, so I'm not sure if something changed with geom_vlineor if my code is simply not correct due to new data or a small change that I might have accidentally made.
, .