I forgot to add that I figured how to do a single regression line using:
panel.fitline<-function(x, y, digits=2, prefix="", cex.cor, ...)
{
points(x, y, ...)
reg <- coef(lm(y ~ x))
abline(coef=reg,untf=F,col="blue")
}
and adding: panel=panel.fitline to pairs. But I am not sure how to add
two lines differentiated by cars$tr.
Thank you for your help!
Ben
On 2/18/07, Benjamin Dickgiesser <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to create a plot using pair.
>
> Currently I'm doing the following
>
> pairs(~mpg + hp + wt , data=cars, labels = c("Miles per
> Gallon","Horsepower","Weight"),pch = c(24,25)[unclass(cars$tr + 1)],
> bg = c("red", "green3")[unclass(cars$tr + 1)],panel=panel.smooth)
>
> for the attached dataset. However,instead of using panel.smooth I
> would rather have two fitted regression lines for each car
> transmission type (cars$tr).
> Is this possible?
>
> Thank you
> Ben
>
>
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.