From Martin Maechler <maechler@stat.math.ethz.ch>  Tue Jan 26 09:53:48 1999
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Tue, 26 Jan 1999 10:53:48 +0100
Subject: locator(n=1) or  (n=500)  as S-plus ?
In-Reply-To: <199901191432.PAA21802@sophie.ethz.ch> (message from Martin
 Maechler on Tue, 19 Jan 1999 15:32:22 +0100)
Message-ID: <199901260953.KAA15124@sophie.ethz.ch>

>>>>> "MM" == Martin Maechler <maechler@stat.math.ethz.ch> writes:

    MM> There's a non-compatibility between R and S-plus with the default
    MM> argument of the locator() function.

    MM> R      has locator(n=1)
    MM> S-plus has locator(n=500, type="n", noclick=F)

    MM> S's default is ``better'' I think, insofar as it means in 99% of
    MM> the cases ``user clicks <left> as many times as wanted and then
    MM> clicks <right> to end''

    MM> Ross Ihaka and his grad students are working on improving this
    MM> interface, I believe, however, I'd propose to just change

    MM> the default of n=1 to n=500 (or another "large" integer in order to
    MM> not copy S exactly).

I got 0 feedback..

What about the following new  locator()
which additionally adds a   `msg' argument 

The old behavior is got  by
	locator( *, msg="")  or  
	locator(*, msg=NULL) 

locator <- function(n = 512, 
                    msg = "Click left to locate points;  right to end") 
{
    do.msg <- is.character(msg) && nchar(msg) > 0
    if(do.msg) cat(msg,": ",sep="")
    z <- .Internal(locator(n))# n <= 0 gives error
    if(do.msg) cat("\n")
    x <- z[[1]]
    y <- z[[2]]
    if((n <- z[[3]]) > 0) list(x=x[1:n], y=y[1:n]) 
}


---
Would anyone not like the default of `msg' writing to the console?
I've often been startled by functions using locator() and not prompting
the user to do start clicking in the graphic window at all..

One could also use the new argument

 prompt =
   "Use the graphics window to locate points;\n click left to add, right to end"

Feedback welcome !!

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


locator(n=1) or (n=500) as S-plus ?
Martin Maechler