Learn R Programming

exams.forge (version 1.0.10)

firstmatch: Firstmatch

Description

firstmatch seeks matches for the elements of its first argument among those of its second. For further details please check 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_)

Value

An 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_)

Examples

Run this code
firstmatch("d", c("chisq", "cauchy"))
charmatch("c", c("chisq", "cauchy"))
firstmatch("c", c("chisq", "cauchy"))
firstmatch("ca", c("chisq", "cauchy"))

Run the code above in your browser using DataLab