Supressing "estimate only" message

68 views
Skip to first unread message

William Beasley

unread,
Feb 26, 2013, 9:20:43 PM2/26/13
to lubr...@googlegroups.com
Is it currently possible to suppress the message "estimate only: convert difftimes to intervals for accuracy" when executing something like the following line?
as.period(ymd("2010-01-01") - ymd("2009-11-01")) #From https://github.com/hadley/lubridate/issues/75

Is there a way to suppress this specific message, without suppressing more important warnings that may occur?

If not, would t be helpful if I forked lubridate and modified this method from
setMethod("as.period", signature(x = "difftime"), function(x, unit = NULL, ...){
  message("estimate only: convert difftimes to intervals for accuracy")
  seconds_to_period(as.double(x, "secs"))
})

to something like

setMethod("as.period", signature(x = "difftime"), function(x, unit = NULL, showAccuracyWarning=TRUE, ...){
  if( showAccuracyWarning ) message("estimate only: convert difftimes to intervals for accuracy")
  seconds_to_period(as.double(x, "secs"))
})
?

To make the signatures and behavior consistent, I suppose these two lines show be modified as well.

I really like the period concept in lubridate.  I deal with human age a lot, such as if kids were eligible for a specific government program during a past event.  The period `10y 0m 1d` is more accurate/appropriate than dividing a difftime of 3653 days by 365.25.  It's even more important when the eligibility threshold is 6 months or 34 months old.

William Beasley

unread,
Mar 21, 2013, 1:25:32 PM3/21/13
to lubr...@googlegroups.com
I've reposted this in GitHub: https://github.com/hadley/lubridate/issues/173
Reply all
Reply to author
Forward
0 new messages