[R] Multiple ablines

G. Alex Janevski galexski at umich.edu
Fri Apr 7 22:45:57 CEST 2006

Thanks in advance,

I have searched and read the archives extensively and have been unable 
to find a question (solution) exactly mimicking my problem. I have 
created a scatterplot simulation of data through which I have drawn a 
linear regression in this manner:

points(y~x, pch="*", col="black")
abline(fm, col="red")

This works. The problem arises in that I would like to run my simulation 
multiple times, to plot the data points together on the same plot, and 
more importantly the regression lines of the simulated data. Therefore, 
I have placed the code within the loop of the simulation. This works 
fine for points(), I can watch the additional points being added to the 
plot as the simulations run. However, when I include abline() it gives 
this error: "Error in abline(a, b, h, v, untf, col, lty, lwd, ...) :
        'a' and 'b' must be finite"

I can take the code as written and place it outside of the loop and it 
works fine, plotting the points and regression line for the data of the 
last run of the simulation. And as I said I can plot all of the points 
from the multiple simulations. However, I cannot plot the regressions of 
those points together. Additionally, I have set the loop to one 
iteration and received the same error. I would greatly appreciate 


More information about the R-help mailing list