Examples for 'od::od_filter'


Filter OD datasets

Aliases: od_filter

Keywords:

### ** Examples

x = od_data_df
z = od_data_zones
codes = z[[1]]
z_in_x_o = codes %in% x[[1]]
z_in_x_d = codes %in% x[[2]]
sum(z_in_x_d)
[1] 2
sum(z_in_x_o)
[1] 6
z = z[which(z_in_x_o | z_in_x_d)[-1], ]
z[[1]]
[1] "E02002392" "E02002404" "E02006861" "E02006875" "E02006876"
unique(c(x[[1]], x[[2]]))
[1] "E02002384" "E02002404" "E02006875" "E02006876" "E02006861" "E02002392"
try(od_to_sf(x, z)) # fails
1 origins with no match in zone ids
0 destinations with no match in zone ids
Error in st_geometry.sf(x) : 
  attr(obj, "sf_column") does not point to a geometry column.
Did you rename it, without setting st_geometry(obj) <- "newname"?
nrow(x)
[1] 7
x = od_filter(x, z[[1]])
1 origins with no match in zone ids
0 destinations with no match in zone ids
nrow(x)
[1] 6
od_to_sf(x, z)
0 origins with no match in zone ids
0 destinations with no match in zone ids
Error in st_geometry.sf(x): attr(obj, "sf_column") does not point to a geometry column.
Did you rename it, without setting st_geometry(obj) <- "newname"?

[Package od version 0.5.1 Index]