first_match_index: Row operation that creates a vector of indices of the first...

first_match_indexR Documentation

Row operation that creates a vector of indices of the first match of a pattern

Description

Row operation that creates a vector of indices of the first match of a pattern

Usage

first_match_index(data, new_name, colvec, pattern)

Arguments

data

input data

new_name

proposed name for the new variable

colvec

selected columns to match

pattern

the pattern to match

Value

return the vector of the indices of the matches with 0 for no match

Examples


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")


epinotes/injurymatrix documentation built on July 28, 2022, 12:34 a.m.