0

I am trying to create a scatter plot between 2 variables, 'score' and 'avg_bty'.

I created avg_bty and I'm not sure what it means when it says "must be same length as the data" because the 2 variables have the same amount of readings.

creating variable:

evals %>% 
  rowwise() %>% 
  mutate(avg_bty = (bty_f1lower+ bty_f1upper+bty_f2upper+bty_m1lower+bty_m1upper+bty_m2upper)/6)

scatterplot:

  ggplot(data = evals, mapping = aes(score, avg_bty))+
  geom_point()

I keep getting Error: Aesthetics must be either length 1 or the same as the data (463): y.

  • 5
    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. Is `score` a column in `evals`? – MrFlick Nov 11 '19 at 21:20
  • 4
    In addition to MrFlick's comment, there shouldn't be a need for `rowwise()` here. Addition in R is vectorised. – Maurits Evers Nov 11 '19 at 21:30
  • ...though you may be interested in the `rowMeans` function. – Gregor Thomas Nov 11 '19 at 22:26

0 Answers0