Skip to content

symbols: xlim and ylim cannot be specified (PR#639)

4 messages · Martin Maechler, Uwe Ligges, Peter Dalgaard

#
[now I'm not CC'ing R-bugs, since this is not about the bug anymore..]

        
BDR> On Tue, 22 Aug 2000 maechler@stat.math.ethz.ch wrote:
.............

    >> yes,
    >> and Uwe's fix cures this problem.
    >> and I have committed it for the release patches (!! i.e. "1.1.1 patched")

which has
		ylab = "", xlim = NULL, ylim = NULL, ...)
and later
		if(is.null(xlim)) { 
		   ... 
		}

    BDR> Why is using NULL preferable here?  The standard paradigm as I
    BDR> understand it is

    BDR> ylab = "", xlim, ylim, ...)
    BDR> ...
    BDR> if(missing(xlim)) {
    BDR>   xlim <- range(x, na.rm = TRUE)
    BDR>   xlim <- xlim + c(-1, 1) * (0.1 * diff(xlim))
    BDR> }

    BDR> In S there is a problem with passing down missingness, but not in R.

I know.  Note however that to be really useful one would have to able to
also *set* missingness for an argument (which I think we can't currently)

I might want to call

	symbols(.very.long.argument.list.etc.etc., 
                xlim = if(<something>) my.xlim else <<DEFAULT>>,
		...)

where with the NULL setup, I can even drop the else clause
{since  if(FALSE)  evaluates to NULL},
but with the   missing(xlim)  paradigm, I should be able to set <<DEFAULT>>
to missing...

In short, we (Uwe, people here and me) *do* prefer NULL to missing...

Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Martin Maechler wrote:
You are right.
Especially in the development of the scatterplot3d() function I have had
some problems with missing arguments (not only xlim), so I decided to
work with NULL as default instead of "missing".
And I don't see any problems so far.
The only reason to use "missing" is the "standard paradigm" argument, as
Prof. Ripley mentioned.

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Uwe Ligges <ligges@statistik.uni-dortmund.de> writes:
...
Also the fact that all those NULL defaults tend to clutter up the
code... 

I tend to see it the way that the "standard paradigm" is well
intended, but flawed -- mostly in the S incarnation, but also in R for
the reasons that Martin poins out. So another option could be to
fix things so that the paradigm worked.

Do we want to reconsider the semantics and include a "missing
constant"? In fact we have one (don't look now, Robert!):

missing.value<-quote()
missing(missing.value)
f<-function(x)missing(x)
f(missing.value)
y<-missing.value

However, things are not all that simple, e.g. constructions like

g<-function(y,x=if (y) 2 else missing.value) missing(x)

returns TRUE both for g(TRUE) and g(FALSE)

That actually makes sense, but this is perplexing:
[1] FALSE
[1] FALSE
[1] 2
Error in print(x) : Argument "missing.value" is missing, with no default

[You don't need to mess with missing.value to create this kind of
effect:
[1] TRUE
[1] FALSE

]
#
PD> Uwe Ligges <ligges@statistik.uni-dortmund.de> writes:
    >> > I know.  Note however that to be really useful one would have to
    >> able to > also *set* missingness for an argument (which I think we
    >> can't currently)
    >> > 
    >> > I might want to call
    >> > 
    >> > symbols(.very.long.argument.list.etc.etc., > xlim =
    >> if(<something>) my.xlim else <<DEFAULT>>, > ...)
    >> > 
    >> > where with the NULL setup, I can even drop the else clause >
    >> {since if(FALSE) evaluates to NULL}, > but with the missing(xlim)
    >> paradigm, I should be able to set <<DEFAULT>> > to missing...
    >> > 
    >> > In short, we (Uwe, people here and me) *do* prefer NULL to
    >> missing...
    >> 
    >> You are right.
    PD> ...
    >> The only reason to use "missing" is the "standard paradigm"
    >> argument, as Prof. Ripley mentioned.

    PD> Also the fact that all those NULL defaults tend to clutter up the
    PD> code...
yes, the argument list

    PD> I tend to see it the way that the "standard paradigm" is well
    PD> intended, but flawed -- mostly in the S incarnation, but also in R
    PD> for the reasons that Martin poins out. So another option could be
    PD> to fix things so that the paradigm worked.
yes!

    PD> Do we want to reconsider the semantics and include a "missing
    PD> constant"? In fact we have one (don't look now, Robert!):

	[ `missing' spaces around "<-" added (above and below) by MM  ... ]

    >> missing.value <- quote()
    >> missing(missing.value)
    >> f <- function(x)missing(x)
    >> f(missing.value)
    >> y <- missing.value

wow!  (I  thought about you when I wrote above
       ``*set* missingness for an argument (which I think we can't currently)''
						  ^^^^^^^
      )						 

    PD> However, things are not all that simple, e.g. constructions like

    >> g <- function(y,x=if (y) 2 else missing.value) missing(x)

    PD> returns TRUE both for g(TRUE) and g(FALSE)

    PD> That actually makes sense,
yes

    PD> but this is perplexing:

    >> f <- function(x)missing(x)
    >> g <- function(y,x=if(y)2 else missing.value)f(x)
    >> g(F)
    PD> [1] FALSE
    >> g(T)
    PD> [1] FALSE
    >> g <- function(y,x=if(y)2 else missing.value)print(x)
    >> g(T)
    PD> [1] 2
    >> g(F)
    PD> Error in print(x) : Argument "missing.value" is missing, with no default

    PD> [You don't need to mess with missing.value to create this kind of
    PD> effect: 

    >> g <- function(y,x=y)f(x)
    >> g()
    PD> [1] TRUE
    >> g <- function(y,x=(y))f(x)
    >> g()
    PD> [1] FALSE

(that's a bug in the passing of "missingness", right ?)

--------

Coming back to your proposition:

Yes I think it's worth considering to make your "missing.value" a new
language constant.  However, the name "missing.value" is too easily
confused by what we (statisticians) usually  use  `NA' for.

Coffee discussion here lead to one of
       missing.argument
       missing.arg
or     MARG

So, this would need to
1)  declare "MARG" (or whatever)
    a constant, the same as "NA" or "NULL" or "TRUE"
2)  Maybe define a ``print method'' for it,
    the problem being that using a class or changing print.default() is not
    going to work, since the *generic*  print() now already gives the error

        Error in print(x) : Argument "MARG" is missing, with no default

   Hence, print may be changed to something like

     print <- function (x, ...) {
	 if(missing(x))
	     return(print("<<missing argument>>", quote = FALSE, ...))
	 UseMethod("print")
     }

     MARG <- quote()

     MARG ## still does not work !
     (MARG)## neither
     print(MARG) # does work

which is somewhat perplexing : 
There must be an internal extra "if(missing(.))"  even *before* print() is
called ...

Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._