Dear Gang,
Try this:
nn <- c(1, 0, 0, 1, 0, 1,0)
paste(nn,sep="",collapse="")
See ?paste for more information.
HTH,
Jorge
On Thu, Apr 9, 2009 at 5:23 PM, Gang Chen <gangchen6@gmail.com> wrote:
> I have some bits stored like the following variable nn
>
> (nn <- c(1, 0, 0, 1, 0, 1,0))
> [1] 1 0 0 1 0 1 0
>
> not in the format of
>
> 1001010
>
> and I need to convert them to numbers in base 10. What's an easy way to
do
> it?
>
> TIA,
> Gang
>
> ______________________________________________
> 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.
>
[[alternative HTML version deleted]]