From @oko| @end|ng |rom |n@@-tou|ou@e@|r  Tue Oct  1 10:58:46 2019
From: @oko| @end|ng |rom |n@@-tou|ou@e@|r (Serguei Sokol)
Date: Tue, 1 Oct 2019 10:58:46 +0200
Subject: [Rd] Is missingness always passed on?
In-Reply-To: <1fc5777f-cc96-ceb7-f2e4-4475622ce77b-860@gmail.com>
References: <1fc5777f-cc96-ceb7-f2e4-4475622ce77b-860@gmail.com>
Message-ID: <34912961-8e67-4c78-865d-e524e207a684@insa-toulouse.fr>

Le 30/09/2019 ? 16:17, Duncan Murdoch a ?crit?:
>
> There's a StackOverflow question 
> https://stackoverflow.com/q/22024082/2554330 that references this text 
> from ?missing:
>
> "Currently missing can only be used in the immediate body of the 
> function that defines the argument, not in the body of a nested 
> function or a local call. This may change in the future."
>
> Someone pointed out (in https://stackoverflow.com/a/58169498/2554330) 
> that this isn't true in the examples they've tried:? missingness does 
> get passed along.? This example shows it (this is slightly different 
> than the SO example):
>
> f1 <- function(x, y, z){
> ? if(missing(x))
> ??? cat("f1: x is missing\n")
> ? if(missing(y))
> ??? cat("f1: y is missing\n")
> }
>
> f2 <- function(x, y, z){
> ? if(missing(z))
> ??? cat("f2: z is missing\n")
> ? f1(x, y)
> }
>
> f2()
>
> which produces
>
> f2: z is missing
> f1: x is missing
> f1: y is missing
>
> Is the documentation out of date?? That quote appears to have been 
> written in 2002.
Er, as far? as I understand the cited doc, it correctly describes what 
happened in your example: missing() is not working in a local call (here 
f1(x,y)).
In fact, what missing() of f1 is reporting it is still the situation of 
f2() call (i.e. immediate body of the function). See

f2(y=1)

produces

f2: z is missing
f1: x is missing

(the line about y missing disappeared from f1(x,y) call, what needed to 
be demonstrated).

Best,
Serguei.



[Rd] Is missingness always passed on?
Serguei Sokol