[R] reverse lexicographic order
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Dec 15 08:20:06 CET 2003
On 14 Dec 2003, Peter Dalgaard wrote:
> Thomas W Blackwell <tblackw at umich.edu> writes:
>
> > Murray -
> >
> > If you could guarantee that all of the email addresses have
> > exactly one occurrence of the "@" character in them, then
> > something like
> ....snip....
>
> Otherwise, try something like this (I don't think we have a string
> reversal function anywhere, do we?):
Only in the examples for strsplit ....
>
> > mychar <- scan(what="")
> 1: I have some email addresses that I would like to sort in reverse
> 14: lexicographic order so that addresses from the same domain will be
> 25: grouped together. How might that be done?
> 32:
> Read 31 items
> >
> >mychar[order(sapply(lapply(strsplit(mychar,""),rev),paste,collapse=""))]
> [1] "together." "done?" "I" "I"
> [5] "lexicographic" "grouped" "would" "be"
> [9] "be" "the" "like" "same"
> [13] "some" "reverse" "have" "email"
> [17] "will" "from" "in" "domain"
> [21] "so" "to" "order" "addresses"
> [25] "addresses" "that" "that" "that"
> [29] "might" "sort" "How"
>
>
>
> > > Hi all,
> > >
> > > I have some email addresses that I would like to sort in reverse
> > > lexicographic order so that addresses from the same domain will be
> > > grouped together. How might that be done?
> > >
> > > Murray
> > >
> > > --
> > > Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html
> > > Department of Statistics, University of Waikato, Hamilton, New Zealand
> > > Email: maj at waikato.ac.nz Fax 7 838 4155
> > > Phone +64 7 838 4773 wk +64 7 849 6486 home Mobile 021 1395 862
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch mailing list
> > > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > >
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >
>
>
--
Brian D. Ripley, ripley at 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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list