I want to add a random curve to a plot to test whats fitting best to my data.
df <- data.frame(a = c(-1.973, -1.685, 2.050, 0.496, 3.310, 2.604, 1.477, 5.552, 2.039, 1.503, 2.171, 1.095),
b = c(21,27,36,36,66,53,40,40,65,39,37,32))
lm(b~a,data = df)plot(df$a, df$b, xlab = "a", ylab = "b")
x<-lm(df$b~df$a)$coefficients[1]
curve(x+lm(df$b~df$a)$coefficients[2], add=TRUE, col="red")
Though this plot I can draw a regression line (picture) but can I also add a random curve?
When I run the code, I only see the curve and not the data. Camn anyone help what I have to do that the data and the curve is visible? Thanks...