From pdalgd at gmail.com  Sat Nov 19 09:13:15 2011
From: pdalgd at gmail.com (peter dalgaard)
Date: Sat, 19 Nov 2011 09:13:15 +0100
Subject: [Rd] round() ignores missing arguments if it is used inside
	another function where some arguments are missing.
In-Reply-To: <CAFDcVCRJ9xxpCQxo3sk+_97c6gpFq5WvpLpf08MT0j8T=hpPuA@mail.gmail.com>
References: <CAO1zAVaS6YN=7V7tciOpgDA98haDY3wPYyuQt-cxkcsqXGsz=A@mail.gmail.com>
	<1321632620.17906.68.camel@prometheus.geog.ucl.ac.uk>
	<CAO1zAVYLrLFLdPQkm8Wt=dTAoijqHP83a2tVRBaTXybPWNv8wA@mail.gmail.com>
	<4EC69740.6010405@gmail.com>
	<CAFDcVCRJ9xxpCQxo3sk+_97c6gpFq5WvpLpf08MT0j8T=hpPuA@mail.gmail.com>
Message-ID: <0C855C67-A6E6-4B6B-84EB-F64AF363E1AF@gmail.com>


On Nov 19, 2011, at 04:35 , Henrik Bengtsson wrote:

> On Fri, Nov 18, 2011 at 9:34 AM, Kevin R. Coombes
> <kevin.r.coombes at gmail.com> wrote:
>> You can also see the odd behavior without wrapping round in another
>> function:
>> 
>>> round(100.1, digits=)
>> [1] 100
> 
> Hmm... is there a reason for why the parser accepts that construct?

Yes. See e.g. help(alist) for actual usage. 

It can also be used to pass empty arguments to FUN in apply-constructs:

a <- matrix(1:12, 3, 4)
f <- function(i, j) a[i,j]
lapply(1:4, f, i=)


> Some example:
> 
>> parse(text="f(a=)")
> expression(f(a=))
> 
>> parse(text="f[a=]")
> expression(f[a=])
> 
>> parse(text="(a=)")
> Error in parse.default(text = "(a=)") : <text>:1:4: unexpected ')'
> 1: (a=)
> 
> /Henrik
> 
>> 
>> On 11/18/2011 10:19 AM, Joris Meys wrote:
>>> 
>>> On Fri, Nov 18, 2011 at 5:10 PM, Gavin Simpson<gavin.simpson at ucl.ac.uk>
>>>  wrote:
>>>> 
>>>> round is indicated to not evaluate its arguments. I don't follow the C
>>>> code well enough to know if it should be catching the missing argument
>>>> further on - it must be because it is falling back to the default, but
>>>> the above explains that the not evaluating arguments is intended.
>>>> 
>>>> G
>>> 
>>> So if I understand it right, the y argument is not evaluated in the
>>> fun2 function but deeper in the C code. that explains the lack of the
>>> error message, thanks! I keep on learning every day.
>>> Cheers
>>> 
>>> Joris
>>> 
>> 
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> 
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] round() ignores missing arguments if it is used inside another function where some arguments are missing.
peter dalgaard