Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:19:06+00:00 2026-06-10T06:19:06+00:00

How to convert an integer number into binary vector using R? For example :

  • 0

How to convert an integer number into binary vector using R?

For example :

number <- 11
[1] 1 0 1 1

what is the fastest possible method of conversion (using R code or some existing functions from packages) if I need to convert whole vector of numbers (minimum value = 0, maximum =300) into binary matrix ?

Follow the rabbit :
base::intToBits

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:19:08+00:00Added an answer on June 10, 2026 at 6:19 am

    There’s the intToBits function that converts any integer to a vector of 32 raws, so you can do this:

    decimals <- c(3,5,11,4)
    m <- sapply(decimals,function(x){ as.integer(intToBits(x))})
    m
    
    > m
          [,1] [,2] [,3] [,4]
     [1,]    1    1    1    0
     [2,]    1    0    1    0
     [3,]    0    1    0    1
     [4,]    0    0    1    0
     [5,]    0    0    0    0
     [6,]    0    0    0    0
     [7,]    0    0    0    0
     [8,]    0    0    0    0
     [9,]    0    0    0    0
    [10,]    0    0    0    0
    [11,]    0    0    0    0
    [12,]    0    0    0    0
    [13,]    0    0    0    0
    [14,]    0    0    0    0
    [15,]    0    0    0    0
    [16,]    0    0    0    0
    [17,]    0    0    0    0
    [18,]    0    0    0    0
    [19,]    0    0    0    0
    [20,]    0    0    0    0
    [21,]    0    0    0    0
    [22,]    0    0    0    0
    [23,]    0    0    0    0
    [24,]    0    0    0    0
    [25,]    0    0    0    0
    [26,]    0    0    0    0
    [27,]    0    0    0    0
    [28,]    0    0    0    0
    [29,]    0    0    0    0
    [30,]    0    0    0    0
    [31,]    0    0    0    0
    [32,]    0    0    0    0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to convert an integer number into its binary representation? I'm using this code:
I want to convert a binary number into a float number. Here's an example
I need to convert an integer into a base64-character representation. I'm using OxA3's answer
I'm trying to to convert from a decimal number into a binary number. Have
I would like to convert a binary number writen in a String into its
How to convert a whole number into decimal..For example 70 to .70 because there
Using PHP, I'd like to convert a string containing a Roman number into its
I am trying to convert an integer number in C into an array containing
How to convert a number printed in a string into integer? Thank you.
Possible Duplicate: How can I convert an integer into its verbal representation? I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.