ez.match: kinda like filter(), but the order of rows are in the order...

View source: R/frame.R

ez.matchR Documentation

kinda like filter(), but the order of rows are in the order of vec

Description

kinda like filter(), but the order of rows are in the order of vec

Usage

ez.match(df, col, vec, nomatch = 0)

Arguments

col

a single col name

vec

elements; see note

nomatch

if 0, not return a row for the nomatch; if NA/NULL, return NA.

Value

returns a new data frame with rows in df[[col]] matching the vec elements. row names are normal (1:nrow)

Note

works best if your vec contains exactly the same elements as df[[col]], and neither contain duplicate values
Actually, duplicated elements in vec OK, will be mathched multiple times. Duplicates in df[[col]] will be picked using first match. For example, df[[col]] has two rows id1_col2, id1_col1, vec = c(id1,id1), then returns two rows id1_col2, id1_col2.


jerryzhujian9/zmisc documentation built on March 9, 2024, 12:49 a.m.