base::match() andbase::%in% are not generics, so we can't just define Arrow methods forthem. These functions expose the analogous functions in the Arrow C++ library.
Value
match_arrow() returns anint32-type Arrow object of the same lengthand type asx with the (0-based) indexes intotable.is_in() returns aboolean-type Arrow object of the same length and type asx with values indicatingper element ofx it it is present intable.
Examples
# note that the returned value is 0-indexedcars_tbl<-arrow_table(name=rownames(mtcars),mtcars)match_arrow(Scalar$create("Mazda RX4 Wag"),cars_tbl$name)#> Scalar#> 1is_in(Array$create("Mazda RX4 Wag"),cars_tbl$name)#> Array#> <bool>#> [#> true#> ]# Although there are multiple matches, you are returned the index of the first# match, as with the base R equivalentmatch(4,mtcars$cyl)# 1-indexed#> [1] 3match_arrow(Scalar$create(4),cars_tbl$cyl)# 0-indexed#> Scalar#> 2# If `x` contains multiple values, you are returned the indices of the first# match for each value.match(c(4,6,8),mtcars$cyl)#> [1] 3 1 5match_arrow(Array$create(c(4,6,8)),cars_tbl$cyl)#> Array#> <int32>#> [#> 2,#> 0,#> 4#> ]# Return type matches type of `x`is_in(c(4,6,8),mtcars$cyl)# returns vector#> Array#> <bool>#> [#> true,#> true,#> true#> ]is_in(Scalar$create(4),mtcars$cyl)# returns Scalar#> Scalar#> trueis_in(Array$create(c(4,6,8)),cars_tbl$cyl)# returns Array#> Array#> <bool>#> [#> true,#> true,#> true#> ]is_in(ChunkedArray$create(c(4,6),8),cars_tbl$cyl)# returns ChunkedArray#> ChunkedArray#> <bool>#> [#> [#> true,#> true,#> true#> ]#> ]