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. Thanks again! ______________________________________________ R-help@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 [[alternative HTML version deleted]]
?????? <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"
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 > >
Gabor Grothendieck <ggrothendieck <at> myway.com> writes:
:
: ?????? <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"
And just as a follow up to my own post, if you want to make this a bit more
general you might use ascii in place of letters where ascii is defined in:
http://www.r-project.org/nocvs/mail/r-help/2002/0952.html