I believe you are looking for analysis of covariance.
I recommend the ancova function in the HH package.


## install.packages("HH") ## if needed
library(HH)

tmp <- ancova(y ~ x + group, data=mydata)
tmp

## You suggested that you want the superpose panel. You can get
## that on a single page with the last page from
update(attr(tmp, "trellis"), layout=c(1,1))


On Fri, Jan 20, 2012 at 10:38 AM, Sam Chand <sam.cs2...@gmail.com> wrote:

> Hello,
> I have 2 variables - x and y, that belong to separate groups.
> I want to plot all the x and y together, but show separate abline for each
> group. It can be done in ggplot2, but is there a simpler way to draw
> ablines by group?
> e.g.,
>
> mydata <- data.frame(x = 1:20+rnorm(20, -3, 1), y = seq(1,20,by=1), group =
> rep(letters[1:5],20))
> plot(x,y,col=mydata$group)  # need to get separate ablines for each
> color-code
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to