On Sun, Oct 11, 2009 at 8:09 AM, Barry Rowlingson
<b.rowling...@lancaster.ac.uk> wrote:
> On Sun, Oct 11, 2009 at 12:53 PM, Gabor Grothendieck
> <ggrothendi...@gmail.com> wrote:
>> Try this:
>>
>>> library(tcltk)
>>> as.numeric(tcl("string", "reverse", 123))
>> [1] 321
>
> The bit where the original poster said 'unknown length' worried me:
>
>  > as.numeric(tcl("string", "reverse", 12377656534))
> [1] 0.4356568

If you really are dealing with numbers this long pass them as strings:
> as.numeric(tcl("string", "reverse", format(12377656534)))
[1] 43565677321

At some length this will fail too but one can use just strings:
> as.character(tcl("string", "reverse", "12377656534"))
[1] "43565677321"

______________________________________________
R-help@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.

Reply via email to