[Rd] The use of match.fun

Joris Meys jorismeys at gmail.com
Tue Sep 6 15:42:45 CEST 2016


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]]



More information about the R-devel mailing list