Dear Sigrid, This is very easy with the ggplot2 package
install.packages("ggplot2") library(ggplot2) ggplot(data = Your.Data.Frame, aes(x = YEAR, y = YIELD, colour = TREATMENT)) + geom_point() + geom_smooth(method = "lm") + facet_wrap(~Country) Best regards, Thierry > -----Oorspronkelijk bericht----- > Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > Namens Sigrid > Verzonden: zondag 12 juni 2011 21:47 > Aan: r-help@r-project.org > Onderwerp: [R] Side by side scatter plots with specified regression lines > > I am new and self taught in R, so please bear with me. > > I want to create two scatter plots side by side. The data set includes > measurements from two different countries with 7 treatments over a timeline > (x-axis). > > Problem 1 > I want to have each plot to include the data from one of the countries with > 7 regression lines of the treatments, but I do no know how to divide the data > between them. This is how I created one plot with all the data. > > > plot(YEAR,YIELD,col="red",xlab="Year",ylab="Yield",xlim=c(1,4),ylim=c( > > 1,150)) > > Problem 2 > The models I've found to describe the regression lines of the treatments seems > to be different than the default ablines that R creates. I have the values of > the > exact values of intercepts and slopes, but does not know how to add them to > the graph. This is what I got so far. > > > abline(lm(YIELD[TREATMENT=="A"]~YEAR[TREATMENT=="A"]),lty=2,col="1") > > I hope this is enough to give me some pointers, otherwise I will try to > elaborate. > > Thank you for your help. > > -- > View this message in context: http://r.789695.n4.nabble.com/Side-by-side- > scatter-plots-with-specified-regression-lines-tp3592473p3592473.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. ______________________________________________ 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.