[Rd] [Repost 2/3] Why fix all.equal for POSIXct at 1 msec?

From: Dirk Eddelbuettel <edd_at_debian.org>
Date: Sat, 15 Sep 2012 13:37:17 -0500

[ Email repost 2 of 3 ]

  From: Dirk Eddelbuettel <edd_at_debian.org>   To: R-core <R-core_at_r-project.org>, Prof Brian D Ripley <ripley_at_stats.ox.ac.uk>   Subject: Why fix all.equal for POSIXct at 1 msec?   Date: Sat, 28 Jul 2012 10:29:52 -0500      

  In R-devel as of today, the following simple loop   

  edd_at_max:~/svn/r-devel$ ~/bin/R-devel.sh   

  R Under development (unstable) (2012-07-28 r60021) -- "Unsuffered   Consequenc es"
  [...]   

  R> now <- Sys.time(); for (d in seq(-1,-9,by=-1)) { then <- now + 10^d;   cat ("10^", d, " identical(): ", identical(now, then), " and all.equal():   " , all.equal(now, then), " diff of ", difftime(then, now), "\n", sep="")
}

  10^-1 identical(): FALSE and all.equal(): Mean scaled difference: 0.0999999    diff of 0.0999999
  10^-2 identical(): FALSE and all.equal(): Mean scaled difference:   0.00999999 diff of 0.00999999

  10^-3 identical(): FALSE and all.equal(): TRUE diff of 0.000999928
  10^-4 identical(): FALSE and all.equal(): TRUE diff of 9.98974e-05
  10^-5 identical(): FALSE and all.equal(): TRUE diff of 1.00136e-05
  10^-6 identical(): FALSE and all.equal(): TRUE diff of 9.53674e-07
  10^-7 identical(): TRUE and all.equal(): TRUE diff of 0
  10^-8 identical(): TRUE and all.equal(): TRUE diff of 0
  10^-9 identical(): TRUE and all.equal(): TRUE diff of 0
  R>   

  starts reporting all.equal results up to a millisec when identical()   clearly
  shows that a measurable difference is detectable much further.   

  Why stop at a msec? I have using POSIXct to store microsecond data for   half
  a decade, and have been very grateful for how well R supports this. I fear   that having all.equal define such an arbitrary bound will lead people to   infer that R cannot go further than 10^-2 which is clearly wrong.   

  For completeness, on r-release I get      

  R> now <- Sys.time(); for (d in seq(-1,-9,by=-1)) { then <- now + 10^d;   cat ("10^", d, " identical(): ", identical(now, then), " and all.equal():   " , all.equal(now, then), " diff of ", difftime(then, now), "\n", sep="")
}

  10^-1 identical(): FALSE and all.equal(): TRUE diff of 0.0999999
  10^-2 identical(): FALSE and all.equal(): TRUE diff of 0.00999999
  10^-3 identical(): FALSE and all.equal(): TRUE diff of 0.000999928
  10^-4 identical(): FALSE and all.equal(): TRUE diff of 9.98974e-05
  10^-5 identical(): FALSE and all.equal(): TRUE diff of 1.00136e-05
  10^-6 identical(): FALSE and all.equal(): TRUE diff of 9.53674e-07
  10^-7 identical(): TRUE and all.equal(): TRUE diff of 0
  10^-8 identical(): TRUE and all.equal(): TRUE diff of 0
  10^-9 identical(): TRUE and all.equal(): TRUE diff of 0
  R> R.Version()["version.string"]
  $version.string
  [1] "R version 2.15.1 (2012-06-22)"   

  R>      

  Thanks, Dirk   

  --
  Dirk Eddelbuettel | edd@debian.org | http://dirk.eddelbuettel.com

-- 
Dirk Eddelbuettel | edd@debian.org | http://dirk.eddelbuettel.com

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat 15 Sep 2012 - 18:43:01 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 15 Sep 2012 - 19:00:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive