[R] How do I reverse the digits of a number

Gabor Grothendieck ggrothendieck at gmail.com
Sun Oct 11 13:53:33 CEST 2009


Try this:

> library(tcltk)
> as.numeric(tcl("string", "reverse", 123))
[1] 321


On Sat, Oct 10, 2009 at 5:37 PM, tom_p <t.pitt at hotmail.com> wrote:
>
> Hi All,
>
> Thanks for your help.  I need to reverse the digits of a number (unknown
> lenght).  Example 1234->4321
>
> Tom
> --
> View this message in context: http://www.nabble.com/How-do-I-reverse-the-digits-of-a-number-tp25838410p25838410.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list