[R] Thanks

Liaw, Andy andy_liaw at merck.com
Wed Sep 8 05:24:01 CEST 2004


A small drawback to Gabor's proposal:

> "aa" %:% "dd"
[1] "b" "c" "d"
> "00" %:% "99"
character(0)

Defining it as a seq() method for characters is probably not a terribly good
idea, as one should expect it to work for any character vectors as input.
(One can argue that the function worked as `expected', I suppose...)

Best,
Andy

> From: Gabor Grothendieck
> 
> 孟欣 <xmeng <at> capitalbio.com> writes:
> 
> : Thanks a lot for your timely rely.
> : I still wonder whether I can use "a":"d" instead of 1:4.
> : I remember I fulfill it successfully according to the 
> guidance of some 
> materials on R,but fail to find it now.
> 
> You could define your own seq function and operator:
> 
> R> "%:%" <- seq.character <- function(x,y) letters[letters >= 
> x & letters <= y]
> R> seq("a", "d")
> [1] "a" "b" "c" "d"
> R> "a" %:% "d"
> [1] "a" "b" "c" "d"
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list