On Thu, 2006-10-05 at 03:10 +0200, [EMAIL PROTECTED] wrote:
> Full_Name: Brad Christoffersen
> Version: 2.3.1
> OS: Windows XP
> Submission from: (NULL) (128.196.193.132)
> 
> 
> Why is the difference between two numbers so different from the "mean relative
> difference" output from the all.equal() function?  Is this an artifact of the
> way R stores numerics?  I could not find this problem as I searched through 
> the
> submitted bugs. But I am brand new to R so I apologize if there is something
> obvious I'm missing here.
> 
> rm(list=ls(all=TRUE))  ## Remove all objects that could hinder w/ consistent
> output
> a <- 204
> b <- 203.9792
> all.equal(a,b)
> [1] "Mean relative  difference: 0.0001019608"
> a - b
> [1] 0.0208

Read the Details section of ?all.equal, which states:

Numerical comparisons for scale = NULL (the default) are done by first
computing the mean absolute difference of the two numerical vectors. If
this is smaller than tolerance or not finite, absolute differences are
used, otherwise relative differences scaled by the mean absolute
difference.

If scale is positive, absolute comparisons are made after scaling
(dividing) by scale


Thus on R version 2.4.0 (2006-10-03):

> all.equal(a, b, scale = 1)
[1] "Mean scaled  difference: 0.0208"


Please do not report doubts about behavior as bugs.  Simply post a query
on r-help first. If it is a bug, somebody will confirm it and you can
then report it as such.

BTW, time to upgrade...Go Wildcats!

HTH,

Marc Schwartz

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to