0

all! New here. Much more comfortable with SQL but working on an R project. I created a point graph that didn't come out as expected. Here is the code that I entered And the result

I guess I was expecting a straight line through? I'm very new to this so bare with me.

I know this is a broad question but any tips/ resources to help me with data visualization using R? Thanks!

dat.a.tho
  • 59
  • 7

1 Answers1

1

Try geom_smooth() rather than geom_line(). geom_line() will try to draw a line connecting all your individual datapoints, while geom_smooth() will fit a trend line to your data, which sounds like what you want. It uses loess by default, but if you literally want a straight line, you can have it fit a linear model instead with the argument geom_smooth(method = lm).

zephryl
  • 14,633
  • 3
  • 11
  • 30