powered by
as_binary() and from_binary() encode and decode an ip_address vector to a character vector of bits.
as_binary()
from_binary()
ip_address
as_binary(ip)from_binary(bits)
from_binary(bits)
An ip_address vector
A character vector containing only 0 and 1 characters
0
1
as_binary() returns a character vector
from_binary() returns an ip_address vector
The bits are stored in network order (also known as big-endian order), which is part of the IP standard.
IPv4 addresses use 32 bits, IPv6 addresses use 128 bits, and missing values are encoded as NA.
NA
Use as_packed() and from_packed() to encode/decode raw bytes.
as_packed()
from_packed()
# NOT RUN { x <- ip_address(c("192.168.0.1", "2001:db8::8a2e:370:7334", NA)) as_binary(x) from_binary(as_binary(x)) # }
Run the code above in your browser using DataLab