From jorismeys at gmail.com  Tue Sep  6 15:42:45 2016
From: jorismeys at gmail.com (Joris Meys)
Date: Tue, 6 Sep 2016 15:42:45 +0200
Subject: [Rd] The use of match.fun
In-Reply-To: <CAJ=0CtD=J+O5xoe+d5HzVJXb1p55Q2+kOYYwsUMsBXiGSOwS4g@mail.gmail.com>
References: <CAO1zAVYQg+Pa2uAF4OVLGSUk7EMFTMbjmpTpmzEnt8X8mHV1Qw@mail.gmail.com>
	<CAJ=0CtD=J+O5xoe+d5HzVJXb1p55Q2+kOYYwsUMsBXiGSOwS4g@mail.gmail.com>
Message-ID: <CAO1zAVaCAg31nr_Dj0+itxs32U_BFGxOt1L12+D1ndVRmv_fvA@mail.gmail.com>

Sorry, I am being a daft idiot again.  Turns out that somehow I had an
object FUN in my global environment, which explains why I didn't get the
result I expected.

So please ignore my question and burn my mail on a stake.
Cheers
Joris

On Tue, Sep 6, 2016 at 3:35 PM, Adrian Du?a <dusa.adrian at unibuc.ro> wrote:

> I am not able to replicate this:
>
> > center <- function(x,FUN) FUN(x)
> > center(1:10, mean)
> [1] 5.5
> > mean <- 4
> > center(1:10, mean)
> Error in center(1:10, mean) : could not find function "FUN"
>
> Using a fresh install of version 3.3.1 under MacOS, and tested before with
> 3.3.0 with the same result.
>
>
> On Tue, Sep 6, 2016 at 4:25 PM, Joris Meys <jorismeys at gmail.com> wrote:
>
>> Dear gurus,
>>
>> I was utterly surprised to learn that one of my examples illustrating the
>> need of match.fun() doesn't give me the expected result.
>>
>> center <- function(x,FUN) FUN(x)
>> center(1:10, mean)
>> mean <- 4
>> center(1:10, mean)
>>
>> Used to give me the error message "could not find function FUN". Now it
>> just works, even though I didn't expect it to. I believe this is at least
>> partially linked to a change in how R finds functions.
>>
>> Now I'm not sure any more whether match.fun() actually has any use any
>> longer, and if so, in which cases it prevents things going wrong.
>>
>> I've tried to find an example where this went wrong, but couldn't find
>> one.
>> Any pointer to what happened here is greatly appreciated. I've checked the
>> NEWS, but I'm not smart enough to find the relevant bits and piece it
>> together.
>>
>> Thank you in advance
>> Cheers
>> Joris
>>
>> --
>> Joris Meys
>> Statistical consultant
>>
>> Ghent University
>> Faculty of Bioscience Engineering
>> Department of Mathematical Modelling, Statistics and Bio-Informatics
>>
>> tel :  +32 (0)9 264 61 79
>> Joris.Meys at Ugent.be
>> -------------------------------
>> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>
>
> --
> Adrian Dusa
> University of Bucharest
> Romanian Social Data Archive
> Soseaua Panduri nr.90
> 050663 Bucharest sector 5
> Romania
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Mathematical Modelling, Statistics and Bio-Informatics

tel :  +32 (0)9 264 61 79
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]



[Rd] The use of match.fun
Joris Meys