Ian
Ian

Reputation: 103

How to fit a normal curve into this R code?

I'm trying to plot a simple curve over this really tiny data set in R, but the line won't show up on the graph (see photo). Wondering what specifically is wrong with this code:

Decline_Category <- c(1,2,3)
Number_of_Trees <- c(80,15,5)
plot(Decline_Category,Number_of_Trees,pch=19)

fit  <- lm(Number_of_Trees~Decline_Category)
xx <- seq(1,80, length=3)
plot(Decline_Category,Number_of_Trees,pch=19,ylim=c(0,100))
lines(xx, predict(fit, data.frame(=xx)), col="red")

enter image description here

Upvotes: 0

Views: 52

Answers (1)

Katia
Katia

Reputation: 3914

You have a typo in your lines() function: It should be

lines(xx, predict(fit, data.frame(Decline_Category=xx)), col="red")

Upvotes: 2

Related Questions