If I understand you correctly, see ?paste and the following to extract the values you require:
summary(res)[[4]][1] summary(res)[[4]][2] summary(res)[[8]] HTH ashz wrote: > > Dear all, > > How can I covert lm data to text in the form of "y=ax+b, r2" and how do I > calculate R-squared(r2)? > > Thanks. > > Code: > x=18:29 > y=c(7.1,7,7.7,8.2,8.8,9.7,9.9,7.1,7.2,8.8,8.7,8.5) > res=lm(y~x) > -- View this message in context: http://r.789695.n4.nabble.com/Howto-convert-Linear-Regression-data-to-text-tp3766230p3767009.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.