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

Prof Brian Ripley Prof Brian Ripley <ripley@stats.ox.ac.uk>
Tue, 26 Jan 1999 11:47:24 +0000 (GMT)


Martin,

I would much rather you fixed the lack of a type= argument first:
without that the use of n > 1 is not very much use as there can be no
feedback to the user.

S-PLUS devices give some feedback by changing the cursor: R devices I
have seen do not.


> Date: Tue, 26 Jan 1999 10:53:48 +0100
> From: Martin Maechler <maechler@stat.math.ethz.ch>
> To: R-devel@stat.math.ethz.ch
> Subject: Re: locator(n=1) or  (n=500)  as S-plus ?
> 
> >>>>> "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).
> 
Why not 99999 or whatever?


> 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?


Could you make sure it puts out a "\n" as well?  Unfinished lines
in the middle of output are a visual pain, and on line-buffered devices
may not appear at all.


> I've often been startled by functions using locator() and not prompting
> the user to do start clicking in the graphic window at all..

R misses one of S-PLUS's visual clues, of course.



-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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