Hello everyone, I'm very new to R coding and I've been doing exercises to help myself learn the language.
I'm trying to use ggplot2 to help plot models of some data and I'm having some issues.
This is my data, x1 is the input and y1 the output:
When I try to model the data using a 1st degree polynomial, it all works fine until I try to plot using ggplot where I get a huge zig zag, I'll paste my coding and if someone could help me out that would be much appreciated!
Fit1<-lm(y1~x1,data = data1)
Then when I try to plot the fit using gg plot:
ggplot(data1, aes(x=x1, y=y1)) +geom_point(size=3, shape=19,color="red") + * geom_smooth(method="lm",formula = y1~x1, data=data1,se=FALSE,linetype="solid", color = "blue", size = 3)
I get the error : Warning message:
'newdata' had 80 rows but variables found have 5 rows
Along with the zigzag.