It occurs to me that Christos' method could be made more flexible by using rle(). That is, before collapsing the digits, you have something like

>foo
[1] 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 0

Then rle(foo) will show you where the boring lead-zeros end, and you can use that value to set the truncation ---- rather than a fixed [1:17] as below.

Carl

quote:
This was what I was looking for to solve the truncate to 17 digits. Thanks a lot.

Now my output looks like this:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ,0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ,0.0998004
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ,0.1996008



On Thu, Sep 25, 2008 at 4:28 PM, Christos Hatzis < christos.hatzis_at_nuverabio.com> wrote:

> paste(rev(as.integer(intToBits(as.integer(x))[1:17])), collapse="")
endquote

______________________________________________
[email protected] 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