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@nuverabio.com> wrote:

> paste(rev(as.integer(intToBits(as.integer(x))[1:17])), collapse="")
>
> -Christos
>
> > -----Original Message-----
> > From: r-help-bounces@r-project.org
> > [mailto:r-help-bounces@r-project.org] On Behalf Of Jason Thibodeau
> > Sent: Thursday, September 25, 2008 4:11 PM
> > To: Duncan Murdoch
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Conversion to Binary (base2)
> >
> > This seems to work well. After playing with it for a while,
> > however, I can't seem to find a way to fix the number of
> > binary digits to say, 17. Am I just missing something, or am
> > I getting lost in the type conversion?
> >
> > The help page for intToBits said parameter n, and I tried
> > that to no avail.
> >
> > On Thu, Sep 25, 2008 at 3:56 PM, Duncan Murdoch
> > <murdoch@stats.uwo.ca>wrote:
> >
> > > On 9/25/2008 3:33 PM, Jason Thibodeau wrote:
> > >
> > >> Hello,
> > >>
> > >> Is there a simple way to take an input, and convert the decimal
> > >> integers to binary? In this case, I have a CSV file, and I need to
> > >> convert the first column of every line to binary.
> > >>
> > >
> > > Yes, the intToBits function does what you want.  It works with raw
> > > vector output and integer vector input, so you need a few type
> > > conversions, but essentially this is simple:
> > >
> > > > x <- 123
> > > > paste(rev(as.integer(intToBits(as.integer(x)))), collapse="")
> > > [1] "00000000000000000000000001111011"
> > >
> > > Duncan Murdoch
> > >
> > >
> >
> >
> > --
> > Jason Thibodeau
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > 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.
> >
> >
>
>
>


-- 
Jason Thibodeau

	[[alternative HTML version deleted]]

