The R Project SVN R

Rev

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

Rev 61150 Rev 61168
Line 43... Line 43...
43
  \item{check.names}{logical indicating if the \code{\link{names}(.)}
43
  \item{check.names}{logical indicating if the \code{\link{names}(.)}
44
    of \code{target} and \code{current} should be compared as well (and
44
    of \code{target} and \code{current} should be compared as well (and
45
    separately from the \code{attributes}).}
45
    separately from the \code{attributes}).}
46
}
46
}
47
\description{
47
\description{
48
    \code{all.equal(x,y)} is a utility to compare \R objects \code{x}
48
    \code{all.equal(x, y)} is a utility to compare \R objects \code{x}
49
    and \code{y} testing \sQuote{near equality}.  If they are different,
49
    and \code{y} testing \sQuote{near equality}.  If they are different,
50
    comparison is still made to some extent, and a report of the
50
    comparison is still made to some extent, and a report of the
51
    differences is returned.    Don't use \code{all.equal} directly in
51
    differences is returned.    Don't use \code{all.equal} directly in
52
    \code{if} expressions---either use \code{isTRUE(all.equal(....))} or
52
    \code{if} expressions---either use \code{isTRUE(all.equal(....))} or
53
    \code{\link{identical}} if appropriate.
53
    \code{\link{identical}} if appropriate.
Line 96... Line 96...
96
all.equal(pi, 355/113)
96
all.equal(pi, 355/113)
97
# not precise enough (default tol) > relative error
97
# not precise enough (default tol) > relative error
98
 
98
 
99
d45 <- pi*(1/4 + 1:10)
99
d45 <- pi*(1/4 + 1:10)
100
stopifnot(
100
stopifnot(
101
all.equal(tan(d45), rep(1,10)))        # TRUE, but
101
all.equal(tan(d45), rep(1, 10)))          # TRUE, but
102
all      (tan(d45) == rep(1,10))       # FALSE, since not exactly
102
all      (tan(d45) == rep(1, 10))         # FALSE, since not exactly
103
all.equal(tan(d45), rep(1,10), tol = 0)  # to see difference
103
all.equal(tan(d45), rep(1, 10), tol = 0)  # to see difference
104
}
104
}
105
\keyword{programming}% is.*
105
\keyword{programming}% is.*
106
\keyword{utilities}
106
\keyword{utilities}
107
\keyword{logic}
107
\keyword{logic}
108
\keyword{arith}
108
\keyword{arith}