Displaying 1 result from an estimated 1 matches for "placey1".
Did you mean:
placey
2012 May 22
1
Adding Text to a Plot
...sample(1:100,10)
y <- 2+3*x+rnorm(10)
# Run the regression
lm1 <- lm(y~x)
# Plotting
plot(x,y, main="Linear Regression", col="red")
abline(lm1, col="blue")
placex <- par("usr")[1]+.1*(par("usr")[2]-par("usr")[1])
placey1 <- par("usr")[3]+.9*(par("usr")[4]-par("usr")[3])
placey2 <- par("usr")[3]+.8*(par("usr")[4]-par("usr")[3])
# HERE: Is this the right way?
text(x=placex, y=placey1,
bquote(R^2 == .(summary(lm1)$r.squared)), adj=c(0,0))
t...