The R Project SVN R

Rev

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

Rev 71303 Rev 72473
Line 1... Line 1...
1
% File src/library/base/man/match.Rd
1
% File src/library/base/man/match.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2016 R Core Team
3
% Copyright 1995-2017 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{match}
6
\name{match}
7
\alias{match}
7
\alias{match}
8
\alias{\%in\%}
8
\alias{\%in\%}
Line 61... Line 61...
61
  simple cases.
61
  simple cases.
62
 
62
 
63
  Exactly what matches what is to some extent a matter of definition.
63
  Exactly what matches what is to some extent a matter of definition.
64
  For all types, \code{NA} matches \code{NA} and no other value.
64
  For all types, \code{NA} matches \code{NA} and no other value.
65
  For real and complex values, \code{NaN} values are regarded
65
  For real and complex values, \code{NaN} values are regarded
66
  as matching any other \code{NaN} value, but not matching \code{NA}.
66
  as matching any other \code{NaN} value, but not matching \code{NA},
-
 
67
  where for complex \code{x}, real and imaginary parts must match both
-
 
68
  (unless containing at least one \code{NA}).
67
 
69
 
68
  Character strings will be compared as byte sequences if any input is
70
  Character strings will be compared as byte sequences if any input is
69
  marked as \code{"bytes"}, and otherwise are regarded as equal if they are
71
  marked as \code{"bytes"}, and otherwise are regarded as equal if they are
70
  in different encodings but would agree when translated to UTF-8 (see
72
  in different encodings but would agree when translated to UTF-8 (see
71
  \code{\link{Encoding}}).
73
  \code{\link{Encoding}}).
Line 114... Line 116...
114
r <- c(1, NA, NaN)
116
r <- c(1, NA, NaN)
115
zN <- c(complex(real = NA , imaginary =  r ), complex(real =  r , imaginary = NA ),
117
zN <- c(complex(real = NA , imaginary =  r ), complex(real =  r , imaginary = NA ),
116
        complex(real =  r , imaginary = NaN), complex(real = NaN, imaginary =  r ))
118
        complex(real =  r , imaginary = NaN), complex(real = NaN, imaginary =  r ))
117
zM <- cbind(Re=Re(zN), Im=Im(zN), match = match(zN, zN))
119
zM <- cbind(Re=Re(zN), Im=Im(zN), match = match(zN, zN))
118
rownames(zM) <- format(zN)
120
rownames(zM) <- format(zN)
119
zM ##--> only two different matches: NA or non-NA NaN
121
zM ##--> many "NA's" (= 1) and the four non-NA's (3 different ones, at 7,9,10)
120
 
122
 
121
length(zN) # 12
123
length(zN) # 12
122
unique(zN) # only two: the "NA" and the first non-NA NaN:
124
unique(zN) # the "NA" and the 3 different non-NA NaN's
123
stopifnot(identical(unique(zN), zN[c(1,7)]))
125
stopifnot(identical(unique(zN), zN[c(1, 7,9,10)]))
124
 
126
 
125
## very strict equality would have 4 duplicates (of 12):
127
## very strict equality would have 4 duplicates (of 12):
126
symnum(outer(zN, zN, Vectorize(identical,c("x","y")),
128
symnum(outer(zN, zN, Vectorize(identical,c("x","y")),
127
                     FALSE,FALSE,FALSE,FALSE))
129
                     FALSE,FALSE,FALSE,FALSE))
128
## removing "(very strictly) duplicates",
130
## removing "(very strictly) duplicates",