But in 2.10.1 patched
> z=function(x){x*2}
> z()
Error in x * 2 : 'x' is missing
[See the posting guide about checking current versions before posting
... My notes say the change was in 2.8.0 and a side effect of
something else rather than deliberate.]
On Thu, 28 Jan 2010, Barry Rowlingson wrote:
> Back in the days of R 2.6, if you did this, you got this:
>
>> z=function(x){x*2}
>> z()
> Error in z() : argument "x" is missing, with no default
>
> But now in this decade we get (for R 2.9 and 2.10):
>
>> z=function(x){x*2}
>> z()
> Error in z() :
> element 1 is empty;
> the part of the args list of '*' being evaluated was:
> (x, 2)
>
> Now I can see (after thinking about it) that what is happening is that
> because of lazy evaluation or something the 'x' isn't getting
spotted
> as being empty until R tries to do x*2, which obviously maps to *(x,2)
> in functional form. It's perfectly correct to say element 1 of the
> args list of '*', being (x,2), is empty.
>
> But which of those two errors above is clearer? I don't suppose much
> can be done about this since it is going to the guts of modern R, and
> I was surprised my initial searches didn't find hordes of confused
> newbies. Just me then. It got me when I was doing a histogram of some
> dates:
>
>> hist(cases)
> Error in inherits(breaks, "POSIXt") :
> element 1 is empty;
> the part of the args list of '.Internal' being evaluated was:
> (x, what, which)
>
> who what which? If the error had been "Error in hist(cases): argument
> 'breaks' is missing, with no default" you wouldn't be
wasting your
> time reading this now...
>
> Barry
>
> --
> blog: http://geospaced.blogspot.com/
> web: http://www.maths.lancs.ac.uk/~rowlings
> web: http://www.rowlingson.com/
> twitter: http://twitter.com/geospacedman
> pics: http://www.flickr.com/photos/spacedman
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
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