first_match_index | R Documentation |
Row operation that creates a vector of indices of the first match of a pattern
first_match_index(data, new_name, colvec, pattern)
data |
input data |
new_name |
proposed name for the new variable |
colvec |
selected columns to match |
pattern |
the pattern to match |
return the vector of the indices of the matches with 0 for no match
dat <- data.frame(x1 = letters[1:3], x2 = c("d", "a", "e")) library(dplyr) library(purrr) dat %>% first_match_index(new_name = "x3", colvec = c(1:2), pattern = "a")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.