[R] xyplot & lmline: error message.

Chuck Cleland ccleland at optonline.net
Mon Sep 28 10:40:14 CEST 2009


On 9/28/2009 4:07 AM, Andrewjohnclose wrote:
> Hi, I am trying to produce an xyplot with a regression line. The data should
> be represented as log/log but when I fit the lmline I receive an error
> message - the plot is fine without the log transformation, but the then the
> plot is meaningless. I know it must be something simple, but I just can't
> see it. Hope someone can help...
> 
> Thanks.

  What do you expect to happen with the values of 0 in Pk?  Have a look
at this:

log(rwpk$Pk)

 [1] -1.108663 -1.698269 -2.551046 -2.796881
 [5] -2.733368 -2.796881 -3.352407 -3.352407
 [9] -4.074542 -3.244194 -4.074542 -4.342806
[13] -3.506558 -5.521461 -4.342806 -4.074542
[17] -4.342806 -3.506558 -4.342806 -4.342806
[21]      -Inf -3.816713 -4.342806 -4.710531
[25] -4.342806      -Inf      -Inf -4.074542
[29] -5.521461 -4.342806 -4.710531 -5.521461
[33] -5.521461 -5.521461 -5.521461 -5.521461
[37]      -Inf      -Inf      -Inf -5.521461
[41]      -Inf      -Inf -5.521461      -Inf
[45]      -Inf      -Inf -5.521461      -Inf
[49]      -Inf      -Inf      -Inf      -Inf
[53]      -Inf -5.521461      -Inf      -Inf
[57]      -Inf      -Inf      -Inf      -Inf
[61]      -Inf      -Inf      -Inf -5.521461

  If you want to ignore the zeros, perhaps you could do this:

library(lattice)

rwpk <- read.csv(file='http://www.nabble.com/file/p25641684/rwpk.csv')

xyplot(log(Pk) ~ log(k), data=subset(rwpk, Pk !=0), type=c('p','r'))

> xyplot(log(Pk)~log(k),data=rwpk,cex=1,
> panel=function(x,y){
> panel.grid(h=-1, v=-1)
> panel.xyplot(x,y,cex=1.0)
> panel.lmline(x,y)
> })
> 
> http://www.nabble.com/file/p25641684/rwpk.csv rwpk.csv 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list