[R] Converting Decimal numbers into Binary

Paul Bernal
2019-12-27T23:41:56Z

Thank you Richard.

Best regards,

Paul

El vie., 27 de diciembre de 2019 4:27 p. m., Richard O'Keefe <
raoknz at gmail.com> escribi?:

> The specific problem you are trying to solve is so constrained that
> you do not need a
> general purpose method.
> You start with a string that contains characters drawn from a *subset*
> of ASCII with
> at most 64 elements.  Accordingly, all you need is a table mapping
> characters to
> 6-character strings.
> table <- c("8" = "001000", w = "111111",
...)
> Then you just split your 28-character string into a character vector,
> index the table with that vector, and paste the results together.
>
> (By the way, at no point in the process do you have the least interest
> in converting
> anything to decimal.)
>
> On Sat, 28 Dec 2019 at 05:31, Paul Bernal <paulbernal07 at gmail.com>
wrote:
> >
> > Dear Jeff,
> >
> > Hope you are doing great. The link I provide below has the results I
am
> > expecting. I am doing a test, trying to convert this string:
> "133m at ogP00PD
> > ;88MD5MTDww at 2D7k" into ascii numbers, then to decimal, and
ultimately,
> into
> > binary. I am trying to recreate the results obtained in the link
below.
> >
> > http://www.it-digin.com/blog/?p=20
> >
> > Hope this answers your question.
> >
> > Thanks for any guidance you can provide,
> >
> > Cheers,
> >
> > Paul
> >
> > El vie., 27 dic. 2019 a las 11:18, Jeff Newmiller (<
> jdnewmil at dcn.davis.ca.us>)
> > escribi?:
> >
> > > Your question is incomplete... what do you expect the result to
be?
> > >
> > > Perhaps [1] is relevant?
> > >
> > > [1]
> > >
>
https://stackoverflow.com/questions/52298995/r-binary-decimal-conversion-confusion-ais-data
> > >
> > > On December 27, 2019 7:42:36 AM PST, Paul Bernal <
> paulbernal07 at gmail.com>
> > > wrote:
> > > >Dear friends,
> > > >
> > > >Hope you are all doing well. I need to find a way to convert
ascii
> > > >numbers
> > > >to six digit binary numbers:
> > > >
> > > >I am working with this example, I converted the string to
ascii, and
> > > >finally to decimal, but I am having trouble converting the
decimal
> > > >numbers
> > > >into their six digit binary representation. The code below is
exactly
> > > >what
> > > >I have so far:
> > > >
> > > >ascii_datformat <- utf8ToInt("133m at
ogP00PD;88MD5MTDww at 2D7k")
> > > >ascii_datformat
> > > >
> > > >Base <- ascii_datformat - 48
> > > >
> > > >ifelse(Base > 40, Base-8, Base)
> > > >
> > > >x <- rev(intToBits(Base))
> > > >dec2bin <- function(x)
paste(as.integer(rev(intToBits(x))), collapse > > > >"")
> > > >dec2bin
> > > >
> > > >any guidance will be greatly appreciated,
> > > >
> > > >Best regards,
> > > >
> > > >Paul
> > > >
> > > >       [[alternative HTML version deleted]]
> > > >
> > > >______________________________________________
> > > >R-help at r-project.org mailing list -- To UNSUBSCRIBE and
more, see
> > > >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.
> > >
> > > --
> > > Sent from my phone. Please excuse my brevity.
> > >
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.