From dusa.adrian at unibuc.ro  Tue Sep  6 15:35:10 2016
From: dusa.adrian at unibuc.ro (=?UTF-8?B?QWRyaWFuIER1yJlh?=)
Date: Tue, 6 Sep 2016 16:35:10 +0300
Subject: [Rd] The use of match.fun
In-Reply-To: <CAO1zAVYQg+Pa2uAF4OVLGSUk7EMFTMbjmpTpmzEnt8X8mHV1Qw@mail.gmail.com>
References: <CAO1zAVYQg+Pa2uAF4OVLGSUk7EMFTMbjmpTpmzEnt8X8mHV1Qw@mail.gmail.com>
Message-ID: <CAJ=0CtD=J+O5xoe+d5HzVJXb1p55Q2+kOYYwsUMsBXiGSOwS4g@mail.gmail.com>

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

	[[alternative HTML version deleted]]



[Rd] The use of match.fun
=?UTF-8?B?QWRyaWFuIER1yJlh?=