[R] Side by side scatter plots with specified regression lines

Sigrid s.stenerud at gmail.com
Sun Jun 12 21:46:44 CEST 2011


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.



More information about the R-help mailing list