[R] Trendline and R square value

David Winsemius dwinsemius at comcast.net
Mon Sep 28 14:15:27 CEST 2009


On Sep 28, 2009, at 6:36 AM, Lathouri, Maria wrote:

> Hi
>
> I would like to display the trendline and the R-square value in a xy  
> scatter in R. For example if I want to plot f vs g I add the  
> trendline using the commands below
>
>> library(quantreg)
>> plot(f,g)
>> abline(rq(g~f))
>

 > plot(f,g)
Error in plot(f, g) : object 'f' not found
 > abline(rq(g~f))
Error in eval(expr, envir, enclos) : object 'g' not found


Anyway, there is a worked example in the help page for rq.

> however I don't know how to display the R2 in the graph.
>
> Thank you in advance.
>
> Kind regards
> Maria


David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list