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 <dickgiesser at gmail.com>
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
>
>