[R] Problem with regression line

CHATTON Anne Anne@Ch@tton @ending from hcuge@ch
Wed Apr 18 15:26:30 CEST 2018


Hello,

I am trying to graph a regression line using the followings:

Age <- c(39, 47, 45, 47, 65, 46, 67, 42, 67, 56, 64, 56, 59, 34, 42, 48, 45,
17, 20, 19, 36, 50, 39, 21, 44, 53, 63, 29, 25, 69)
BloodPressure <- c(144, 220, 138, 145, 162, 142, 170, 124, 158, 154, 162,
150, 140, 110, 128, 130, 135, 114, 116, 124, 136, 142, 120, 120, 160, 158,
144, 130, 125, 175)
SimpleLinearReg1=lm(Age ~ BloodPressure)
summary(SimpleLinearReg1)
eq = paste0("y = ", round(coeff[2],1), "*x ", round(coeff[1],1))
plot(Age, BloodPressure, pch = 16, cex = 1.3, col = "blue",
main = eq, xlab = "Age (Year)", ylab = "Blood Pressure (mmHg)")
abline(SimpleLinearReg1, col="red")
mean(Age)
mean(BloodPressure)
abline(h=142.53, col="green")
abline(v=45.13, col="green")

But I cannot get the regression line. Can anybody tell me what's wrong with the codes ? I would appreciate very much. Thanks for any help.

Anne

	[[alternative HTML version deleted]]




More information about the R-help mailing list