firstmatch: firstmatch

View source: R/firstmatch.R

firstmatchR Documentation

firstmatch

Description

firstmatch seeks matches for the elements of its first argument among those of its second, for details see base::charmatch(). charmatch returns a zero if multiple matches are found, whereas firstmatch returns the first partial match if multiple matches are found.

Usage

firstmatch(x, table, nomatch = NA_integer_)

Arguments

x

character: the values to be matched; converted to a character vector if necessary

table

character: the values to be matched against; converted to a character vector if necessary

nomatch

integer: the value to be returned at non-matching positions (default: NA_integer_)

Value

integer

Examples

firstmatch("d", c("chisq", "cauchy"))
charmatch("c", c("chisq", "cauchy"))
firstmatch("c", c("chisq", "cauchy"))
firstmatch("ca", c("chisq", "cauchy"))

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.