Hello,i'm trying to draw a regression line with my dataframe composed of x and y values ,values of x is in the range -2 and 6 and y values is between -0.5 and 1, since there are cosines and sines in it ,i tried to solve the regression problem as a polynomial but when i tried to plot the line ,line showed up in only -1 and 1 range but i want line to take values between -2 and 6, xlim sadly does not work.

here is the code i have written

df<-read.table("dataxy.csv",header = T)

x<-df[,1]

y<-df[,2]

quadmodel<-lm(y~cos(x), data=df)

a<-quadmodel$coefficients["cos(x)"]

c<-quadmodel$coefficients["(Intercept)"]

xp<-predict.lm(quadmodel,df)

yp<-a*cos(xp)+c

plot(x,y)

lines(xp,yp,col="green")

and this is the result i have got