-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Bug description
When creating objects with data.table::fread() and then using ipaddress::is_within() with them an error is given "Object was created without names"
Expected behaviour:
ipaddress functions should work seamlessly with data.table objects (as they are data.frame objects) or present a more descriptive error if this is not possible.
To Reproduce
library(readr)
library(data.table)
library(dplyr)
library(ipaddress)
# List of input CIDR strings
input_string <- 'address
"20.26.18.114/31"
"20.26.18.120/30"
"20.90.131.116/30"
"20.90.132.64/28"
"51.104.25.140/31"
"51.104.25.152/30"
"51.104.25.176/28"
"51.104.25.192/29"
"51.104.27.0/26"
"74.177.72.32/28"
"74.177.108.64/26"
"131.145.145.192/27"
"172.187.71.96/27"'
# Filter address
ip_address <- ipaddress::as_ip_address("51.104.27.12")
# Create a tibble of the input addresses
filter_df <- readr::read_csv(input_string) %>%
dplyr::mutate(network = ipaddress::as_ip_network(address))
# Create a data.table of the input addresses
filter_dt <- data.table::fread(input = input_string) %>%
dplyr::mutate(network = ipaddress::as_ip_network(address))
# Filter the data.frame version to get only networks that contain the specified ip_address
filtered_df <- filter_df %>%
dplyr::filter(ipaddress::is_within(ip_address, network))
# This throws an error
filtered_dt <- filter_dt %>%
dplyr::filter(ipaddress::is_within(ip_address, network))Additional context
This can be resolved by running tibble::as_tibble() on the data.table object, so it appears as though the tbl or tbl_df class are required by ipaddress functions
Metadata
Metadata
Assignees
Labels
No labels