I am a very new user of R, trying to do a linear fit to data, plot(r2,d) plots my data correctly, I do a linear fit: res = lm(r2~d) gives a fit to the data, but abline(res,col=?red?) displays nothing. Again, I am a novice, but what am I doing wrong? DPW
On 23/01/15 08:39, Dennis P. Weygand wrote:> I am a very new user of R, trying to do a linear fit to data, > > plot(r2,d) > > plots my data correctly, I do a linear fit: > > res = lm(r2~d) > > gives a fit to the data, but > > abline(res,col=?red?) > > displays nothing. Again, I am a novice, but what am I doing wrong?Mixing up your x and y coordinate. Do: plot(d,r2) abline(res,col="red") and all will be in harmony in the Universe. cheers, Rolf Turner -- Rolf Turner Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 Home phone: +64-9-480-4619
> > > > plot(r2,d) > > res = lm(r2~d) > > > Mixing up your x and y coordinate. Do: > > plot(d,r2)... or use: plot(r2 ~ d) so that res <- lm(r2 ~ d) uses exactly the same pattern... Olivier. -- Olivier Crouzet, PhD Laboratoire de Linguistique -- EA3827 Universit? de Nantes Chemin de la Censive du Tertre - BP 81227 44312 Nantes cedex 3 France phone: (+33) 02 40 14 14 05 (lab.) (+33) 02 40 14 14 36 (office) fax: (+33) 02 40 14 13 27 e-mail: olivier.crouzet at univ-nantes.fr http://www.lling.univ-nantes.fr/