## first "attach" the data, allowing you to refer ## directly to the variable names. attach(meadow) ## this sets up the axes and labels for the plot without ## plotting the data (this is why type="n"). plot(intensity,flowers,type="n",xlab="Intensity",ylab="Flowers") ## add points to the plot, coded "0" for the "Late" group points(intensity[time==0],flowers[time==0],pch="0") ## add points to the plot, coded "1" for the "Early" group points(intensity[time==1],flowers[time==1],pch="1") ## add a title title("Flowers vs. Intensity, Equal Lines Model") ## fit the regression model. "equal lines model" ## is now an Splus object, containing information ## on the intercept (coefficients[1]) and slope (coefficients[2]) equal.lines.model <- lm(flowers~intensity) ## name the intercept and slope beta0 <- equal.lines.model$coefficients[1] beta.intensity <- equal.lines.model$coefficients[2] ## add a line to the plot with given intercept and slope abline(beta0,beta.intensity)