Vector of IP interfaces
This hybrid class stores both the host address and the network it is on.
ip_interface()
constructs a vector of IP interfaces.
is_ip_interface()
checks if an object is of class ip_interface
.
as_ip_interface()
casts an object to ip_interface
.
ip_interface(...) ## Default S3 method: ip_interface(x = character(), ...) ## S3 method for class 'ip_address' ip_interface(address, prefix_length, ...) is_ip_interface(x) as_ip_interface(x) ## S3 method for class 'character' as_ip_interface(x) ## S3 method for class 'ip_interface' as.character(x, ...) ## S3 method for class 'ip_interface' format(x, exploded = FALSE, ...)
... |
Included for S3 generic consistency |
x |
|
address |
An |
prefix_length |
An integer vector |
exploded |
Logical scalar. Should IPv6 addresses display leading zeros?
(default: |
Constructing an ip_interface
vector is conceptually like constructing an
ip_network
vector, except the host bits are retained.
The ip_interface
class inherits from the ip_address
class.
This means it can generally be used in places where an ip_address
vector is expected. A few exceptions to this rule are:
It does not support addition and subtraction of integers
It does not support bitwise operations
It cannot be compared to ip_address
vectors
The ip_interface
class additionally supports a few functions typically
reserved for ip_network
vectors: prefix_length()
, netmask()
and
hostmask()
.
For other purposes, you can extract the address and network components using
as_ip_address()
and as_ip_network()
.
When comparing and sorting ip_interface
vectors, the network is compared
before the host address.
An S3 vector of class ip_interface
vignette("ipaddress-classes")
# construct from character vector ip_interface(c("192.168.0.1/10", "2001:db8:c3::abcd/45")) # construct from address + prefix length objects ip_interface(ip_address(c("192.168.0.1", "2001:db8:c3::abcd")), c(10L, 45L)) # extract IP address x <- ip_interface(c("192.168.0.1/10", "2001:db8:c3::abcd/45")) as_ip_address(x) # extract IP network (with host bits masked) as_ip_network(x)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.