An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120120/3a1e4a1f/attachment.pl>
abline by groups
3 messages · Sam Chand, Uwe Ligges, Richard M. Heiberger
On 20.01.2012 16:38, Sam Chand 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
1. The code does not run as is. 2. abline for more than two points is nonsense for your data, since the groups are not at all on one line. 3. So you may want separate regressions? Or a whole model of the data with different intercepts and same slope? Or in one model with different intercepts and different slopes? Hence we cannot help and for now I assume this is a homework problem and you have not even repeated the question properly. Uwe Ligges
[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120120/f8ac7c8f/attachment.pl>