r5r
r5r copied to clipboard
bug: too many decimal places in the output of pareto_frontier()
In the output of the pareto_frontier() function, the values in the monetary_cost column have long tail decimal places. Perhaps these values should be rounded to the second decimal place?
reprex
library(r5r)
# build transport network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path = data_path)
# load origin/destination points
points <- read.csv(file.path(data_path, "poa_hexgrid.csv"))[1:5,]
# load fare structure object
fare_structure_path <- system.file(
"extdata/poa/fares/fares_poa.zip",
package = "r5r"
)
fare_structure <- read_fare_structure(fare_structure_path)
departure_datetime <- as.POSIXct(
"13-05-2019 14:00:00",
format = "%d-%m-%Y %H:%M:%S"
)
pf <- pareto_frontier(
r5r_core,
origins = points,
destinations = points,
mode = c("WALK", "TRANSIT"),
departure_datetime = departure_datetime,
fare_structure = fare_structure,
fare_cutoffs = c(4.5, 4.8, 9, 9.3, 9.6)
)
head(pf)
pf$monetary_cost[4]
#> 4.8
pf$monetary_cost[4] == 4.8
#> FALSE
pf$monetary_cost[4] * 10000000000
#> 48000001907
Internally, I recommend doing everything in integers, to avoid floating point roundoff. I ran into this in Boston (I think) where there is one journey that is $8.20, but floor(8.2 * 100) = 819. Better to just convert everything to cents/whatever the indivisible currency units locally are.