Description Usage Arguments Value Author(s) Examples
View source: R/binary-strings.R
Description needed
1 |
i |
Positive integer <= 2^53 (<= 9.007199e+15). |
maxBits |
Maximum number of bits to print (default |
Character vector.
Alex Chubaty
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | x <- sample(0:9999, 10000)
y <- binstr(x) # length is 14 bits
## Not run:
# alternate (but slower) conversion to binary string
R.utils::intToBin(x)
## End(Not run)
# convert binary string to integer value (very fast)
strtoi(y, base = 2)
strtoi(substr(y, 1, 4), base = 2)
strtoi(substr(y, 5, 8), base = 2)
strtoi(substr(y, 9, 11), base = 2)
strtoi(substr(y, 12, 14), base = 2)
# see also `binary()` and `unbinary()` in the `composition` package (requires x11)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.