match: Match Data Frame Rows

View source: R/match.R

matchR Documentation

Match Data Frame Rows

Description

Returns the row indices of a target data frame which match those of a source data frame.

Usage

match(x, ...)

## Default S3 method:
match(x, ...)

## S3 method for class 'data.frame'
match(x, y, by, key, ...)

Arguments

x

Source data frame whose elements will be searched for in the target data frame y.

...

Further arguments passed onto match.

y

Target data frame.

by

Column name(s) which will be used for matching elements. The default is the common column names for x and y.

key

Character vector defining index key.

Methods (by class)

  • match(default): Default match method, see match.

  • match(data.frame): Match rows between two data frames.

Examples

# Create a simple data frame:
x <- data.frame(
        u = c(2, 2, 4),
        v = c(1, 2, 3))

y <- data.frame(
        u = c(1, 1, 1, 1, 2, 2, 2, 3),
        v = c(1, 2, 3, 4, 1, 2, 3, 3))

# Get the list of indices matching the rows of 'x' to 'y':
index <- match(x, y)


TobieSurette/gulf.utils documentation built on Dec. 1, 2024, 6:01 a.m.