match | R Documentation |
Returns the row indices of a target data frame which match those of a source data frame.
match(x, ...)
## Default S3 method:
match(x, ...)
## S3 method for class 'data.frame'
match(x, y, by, key, ...)
x |
Source data frame whose elements will be searched for in the target data frame |
... |
Further arguments passed onto |
y |
Target data frame. |
by |
Column name(s) which will be used for matching elements.
The default is the common column names for |
key |
Character vector defining index key. |
match(default)
: Default match method, see match
.
match(data.frame)
: Match rows between two data frames.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.