[R] Problem with logtrans, from library MASS

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri May 14 11:57:03 CEST 2004


On 14 May 2004, Peter Dalgaard wrote:

> Murray Jorgensen <maj at stats.waikato.ac.nz> writes:
> 
> > Greetings all!
> > 
> > This problem occurs using R 1.8.1 on Windows XP. I downloaded the
> > binaries for R and all packages, including the VR bundle, in December
> > 2003.
> > 
> > The data consists of NZ$ prices and attributes for 643 cars.
> > 
> >  > summary(price)
> >     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's
> >    14290   35800   48990   65400   79000  285000       2
> >  > library(MASS)
> >  > boxcox(price ~ doors+CC+KW+KG+LENGTH, lambda=seq(-0.1,0.5,length=30))
> >  > boxcox(price ~ doors+CC+KW+KG+LENGTH, lambda=seq(-0.5,0.1,length=30))
> > 
> > This all works fine, I get a fairly sharp peak near lambda=-0.25, but then:
> > 
> >  > logtrans(price ~ doors+CC+KW+KG+LENGTH, alpha=seq(-10000,0,length=30))
> > Error in eval(expr, envir, enclos) : Object "price" not found
> > 
> 
> The issue is that logtrans has a 'data' argument that defaults to NULL
> (the author(s) may have a reason for having this inconsistent with
> boxplot?). Adding data=.GlobalEnv seems to work.

It's an R/S difference.  data=NULL or list() in S does give you the normal
search path.  I guess this got noticed for boxplot and not logtrans.

Using a data argument would in any case be a very good idea.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list