From p.dalgaard at biostat.ku.dk  Sat Feb 11 10:43:21 2006
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: 11 Feb 2006 10:43:21 +0100
Subject: [Rd] Arguments of 'transform'
In-Reply-To: <B998A44C8986644EA8029CFE6396A924546AF5@exqld2-bne.qld.csiro.au>
References: <B998A44C8986644EA8029CFE6396A924546AF5@exqld2-bne.qld.csiro.au>
Message-ID: <x2pslucjt2.fsf@turmalin.kubism.ku.dk>

<Bill.Venables at csiro.au> writes:

> If you would like a 10 second R puzzle, you might like to think about
> this one:
> 
> 
> > g <- expand.grid(long = 130:140, lat = -(10:25))
> > gp <- transform(g, x = long, y = lat)
> Error in transform(g, x = long, y = lat) : 
>         object "long" not found
> 
> 
> I don't expect this hasn't come up before, but I can't find mention of
> it.  I suggest that to minimise this little stumbling block for
> beginners (and others) we either
> 
> 	change the name of the principal argument in transform from 'x'
> to, say '.x' (or even 'data' as it is in 'with' for example)  OR
> 
> 	at least put a note in the help file for 'transform' in the
> 'Detalis' section to say
>      
> 	*** NOTE: The only tag name unavailable to be used is 'x'. ***

Yes it has come up before (surprisingly rarely though), and you're
probably right although changing argument names of functions should
never be taken lightly as there could be people using the current
ones. 

> 
> Just another little seed.

...which is connected to my grievances with attach() &c the other day.
Something about transform() just isn't The Right Way.

-- 
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



[Rd] Arguments of 'transform'
Peter Dalgaard