[R] problem with abline

David Winsemius dwinsemius at comcast.net
Thu Oct 7 00:27:27 CEST 2010


On Oct 6, 2010, at 5:56 PM, Gerard Smits wrote:

> Hi All,
>
> I am running a scatter plot and trying to add a best fit line.  I  
> use an abline function, but get no line drawn over the points.

xyplot is Lattice
abline is base graphics

>  I also get no error.  I arm using V 2.10.0 on Windows 7.
>
> Here is my code, including the SAS transport file import:

Nope. Read the Posting Guide about attachments to the list. Nice try,  
though.

>
> require (foreign)
> require (chron)
> require (Hmisc)
> require (lattice)
>
> clin  <- sasxport.get("y:\\temp\\subset.xpt")
> attach(clin)
>
>
> plot.new()
> xyplot(jitter(b.lvef)~jitter(log.fgf),
>       main="Scatter Plot of Baseline Ejection Fraction\nby Log10  
> FGF-23",
>       ylim=c(10,90),
>       ylab="Ejection Fraction", xlab="Log10 FGF-23")

Instead consider:
?panel.lmline

Perhaps (untested in absence of data):

plot.new()
xyplot(jitter(b.lvef)~jitter(log.fgf), panel = function(x, y) {
           panel.xyplot(x, y)
            panel.lmline(x,y)
        },
       main="Scatter Plot of Baseline Ejection Fraction\nby Log10  
FGF-23",
       ylim=c(10,90),
       ylab="Ejection Fraction", xlab="Log10 FGF-23")


>
> abline(lm(b.lvef~log.fgf))
>
> Any suggestions appreciated.
>
> Thanks,
>
> Gerard
> 	[[alternative HTML version deleted]]
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list