[R] Strange behaviour of R?
Rainer Krug
r@|ner_krug @end|ng |rom |c|oud@com
Fri Jan 17 08:41:12 CET 2020
Hi
> On 17 Jan 2020, at 08:33, Sigbert Klinke <sigbert using wiwi.hu-berlin.de> wrote:
>
> Hi,
>
> I wrote a function like
>
> test <- function(FUN, args) {
> print(FUN)
> FUN(args)
> }
>
> When I call it lieke this
>
> test(mean, 1:10)
> test(NULL, 1:10)
>
> then the second call still uses mean, although I set FUN to NULL. Is that ok?
Not for me - macOS, R 3.6.2
>
> Actually, I used something like
>
> test(mean, list(x=1:10, na.rm=TRUE))
Fails as expected,
Rainer
>
> which actually crashed R, but I can not reproduce it. Of course, when I replaced FUN(args) with do.call(FUN, args) then everything works fine.
>
> Sigbert
>
> --
> https://hu.berlin/sk
> https://hu.berlin/mmstat3
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
Orcid ID: 0000-0002-7490-0066
Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland
Office: +41 (0)44 635 47 64
Cell: +41 (0)78 630 66 57
email: Rainer.Krug using uzh.ch
Rainer using krugs.de
Skype: RMkrug
PGP: 0x0F52F982
[[alternative HTML version deleted]]
More information about the R-help
mailing list