0
plot <- Experiment1 %>%
  ggplot(aes(x = factor(Test), y = AbsoluteError )) +
  scale_y_continuous(breaks = seq(0,.8, by =.1)) +
  xlab("Test Type") + 
  ylab("Absolute Error") + 
  ggtitle("Absolute Error Distribution", subtitle = "By Test Type") +
  theme(plot.title = element_text(hjust = 0.5), 
        plot.subtitle = element_text(hjust = 0.5))

I'm plotting a graph that shows absolute error distribution by test type (mult choice, fill ins, etc).

I want to create a value in this that takes the mean of AbsoluteError and if it is greater than the mean Absolute Error, you color it blue and if it is less, you color it red. Can anyone assist me? I've tried multiple mutates but get Error: data must be a data frame, or other object coercible by fortify(), not an S3 object with class uneval.

  • 3
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. You don't seem to have any geoms currently. What did your mutates look like? Have you tried `aes(color=AbsoluteError > mean(AbsoluteError))`? – MrFlick Jul 24 '21 at 01:47
  • That does what I want. However, it separates the data in the scatterplot. The red points are now shifted to the right and the blue points are shifted to the left. I'd like their position not to change. – mypetplant123456 Jul 24 '21 at 01:51
  • 2
    Adding color shouldn't change the position. you really need to provide a reproducible example so we can run the code ourselves and can verify the results. – MrFlick Jul 24 '21 at 02:00
  • The sample size is huge - I don't know how to provide. I can provide a photo. – mypetplant123456 Jul 24 '21 at 02:02
  • 1
    We don't need all your data, just enough to reproduce the problem. See the link I provided previously on how to share a reproducible example. Do not post data as an image. – MrFlick Jul 24 '21 at 02:08

0 Answers0