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
There’s the
intToBitsfunction that converts any integer to a vector of 32 raws, so you can do this: