ez.match | R Documentation |
kinda like filter(), but the order of rows are in the order of vec
ez.match(df, col, vec, nomatch = 0)
col |
a single col name |
vec |
elements; see note |
nomatch |
if 0, not return a row for the nomatch; if NA/NULL, return NA. |
returns a new data frame with rows in df[[col]] matching the vec elements. row names are normal (1:nrow)
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.