]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/r/man/match_arrow.Rd
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / r / man / match_arrow.Rd
CommitLineData
1d09f67e
TL
1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/compute.R
3\name{match_arrow}
4\alias{match_arrow}
5\alias{is_in}
6\title{\code{match} and \code{\%in\%} for Arrow objects}
7\usage{
8match_arrow(x, table, ...)
9
10is_in(x, table, ...)
11}
12\arguments{
13\item{x}{\code{Scalar}, \code{Array} or \code{ChunkedArray}}
14
15\item{table}{\code{Scalar}, Array\verb{, }ChunkedArray`, or R vector lookup table.}
16
17\item{...}{additional arguments, ignored}
18}
19\value{
20\code{match_arrow()} returns an \code{int32}-type Arrow object of the same length
21and type as \code{x} with the (0-based) indexes into \code{table}. \code{is_in()} returns a
22\code{boolean}-type Arrow object of the same length and type as \code{x} with values indicating
23per element of \code{x} it it is present in \code{table}.
24}
25\description{
26\code{base::match()} is not a generic, so we can't just define Arrow methods for
27it. This function exposes the analogous functions in the Arrow C++ library.
28}
29\examples{
30\dontshow{if (arrow_available()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
31# note that the returned value is 0-indexed
32cars_tbl <- arrow_table(name = rownames(mtcars), mtcars)
33match_arrow(Scalar$create("Mazda RX4 Wag"), cars_tbl$name)
34
35is_in(Array$create("Mazda RX4 Wag"), cars_tbl$name)
36
37# Although there are multiple matches, you are returned the index of the first
38# match, as with the base R equivalent
39match(4, mtcars$cyl) # 1-indexed
40match_arrow(Scalar$create(4), cars_tbl$cyl) # 0-indexed
41
42# If `x` contains multiple values, you are returned the indices of the first
43# match for each value.
44match(c(4, 6, 8), mtcars$cyl)
45match_arrow(Array$create(c(4, 6, 8)), cars_tbl$cyl)
46
47# Return type matches type of `x`
48is_in(c(4, 6, 8), mtcars$cyl) # returns vector
49is_in(Scalar$create(4), mtcars$cyl) # returns Scalar
50is_in(Array$create(c(4, 6, 8)), cars_tbl$cyl) # returns Array
51is_in(ChunkedArray$create(c(4, 6), 8), cars_tbl$cyl) # returns ChunkedArray
52\dontshow{\}) # examplesIf}
53}