The R Project SVN R

Rev

Rev 8220 | Rev 38087 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8220 Rev 15168
Line 15... Line 15...
15
}
15
}
16
\details{
16
\details{
17
  Exact matches are preferred to partial matches (those where the value
17
  Exact matches are preferred to partial matches (those where the value
18
  to be matched has an exact match to the initial part of the target,
18
  to be matched has an exact match to the initial part of the target,
19
  but the target is longer).
19
  but the target is longer).
20
    
20
 
21
  If there is a single exact match or no exact match and a unique
21
  If there is a single exact match or no exact match and a unique
22
  partial match then the index of the matching value is returned; if 
22
  partial match then the index of the matching value is returned; if
23
  multiple exact or multiple partial matches are found then \code{0} is
23
  multiple exact or multiple partial matches are found then \code{0} is
24
  returned and if no match is found then \code{NA} is returned.
24
  returned and if no match is found then \code{NA} is returned.
25
}
25
}
26
\author{
26
\author{
27
  This function is based on a C function written by Terry Therneau.
27
  This function is based on a C function written by Terry Therneau.
28
}
28
}
29
\seealso{
29
\seealso{
30
  \code{\link{match}},  \code{\link{pmatch}}.
30
  \code{\link{pmatch}}, \code{\link{match}}.
-
 
31
 
-
 
32
  \code{\link{grep}} or \code{\link{regexpr}} for more general (regexp)
-
 
33
  matching of strings.
31
}
34
}
32
\examples{
35
\examples{
33
charmatch("", "")                             # returns 1
36
charmatch("", "")                             # returns 1
34
charmatch("m",   c("mean", "median", "mode")) # returns 0
37
charmatch("m",   c("mean", "median", "mode")) # returns 0
35
charmatch("med", c("mean", "median", "mode")) # returns 2
38
charmatch("med", c("mean", "median", "mode")) # returns 2