Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anydate sometimes yields NAs #70

Closed
drolejoel opened this issue Jun 29, 2017 · 6 comments
Closed

anydate sometimes yields NAs #70

drolejoel opened this issue Jun 29, 2017 · 6 comments

Comments

@drolejoel
Copy link

drolejoel commented Jun 29, 2017

Hi Dirk, for some input values I am getting NAs. Is this a bug?

Might be related to bug#33 which I reported before but was fixed SOv report

library(anytime)  # V 0.3.0
a <- c("3/22/2013 0:00", "3/21/2012 0:00", "2/19/2014 0:00", "12/5/2013 0:00", "5/8/2013 0:00", "10/15/2010 0:00")
anydate(a)
# [1] "2013-03-22" "2012-03-21" "2014-02-19" NA           NA          
# [6] "2010-10-15"

sessionInfo()

R version 3.3.2 (2016-10-31)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

other attached packages:
[1] anytime_0.3.0

loaded via a namespace (and not attached):
[1] tools_3.3.2 Rcpp_0.12.11 RApiDatetime_0.0.3

@eddelbuettel
Copy link
Owner

Please see #67 which appears to be the same issue which I still cannot reproduce.

Also preferably use current versions. R 3.3.2 is old.

@eddelbuettel
Copy link
Owner

I take that back. User error. You cannot use single digit-months with the Boost parser. That is (as I recall) documented:

> library(anytime)
> dv <-a <- c("3/22/2013 0:00", "3/21/2012 0:00", "2/19/2014 0:00", "12/5/2013 0:00", 
+                   "5/8/2013 0:00", "10/15/2010 0:00")
> dv
[1] "3/22/2013 0:00"  "3/21/2012 0:00"  "2/19/2014 0:00"  "12/5/2013 0:00" 
[5] "5/8/2013 0:00"   "10/15/2010 0:00"
> anytime(dv)
[1] "2013-03-22 07:00:00 CET"  "2012-03-21 00:00:00 CET" 
[3] "2014-02-19 00:00:00 CET"  NA                        
[5] NA                         "2010-10-15 00:00:00 CEST"
> anytime(dv, useR = TRUE)
[1] "2013-03-22 CET"  "2012-03-21 CET"  "2014-02-19 CET"  "2013-12-05 CET" 
[5] "2013-05-08 CEST" "2010-10-15 CEST"
> 

But we now have a fallback as shown.

@drolejoel
Copy link
Author

I tried setting the useR argument to TRUE but saw some weirdness. I'll have to update R and get back to you with my findings.

anydate(a, useR = TRUE)
[1] "3736219-12-27" "3649640-10-17" "3815239-04-08" "3797261-01-27"
[5] "3747338-01-29" "3525922-06-12"

anydate(a, asUTC = TRUE)
[1] "2013-03-22" "2012-03-21" "2014-02-19" NA NA
[6] "2010-10-15"

anydate(a, asUTC = TRUE, useR = TRUE)
[1] "3736219-12-27" "3649640-10-17" "3815239-04-08" "3797261-01-27"
[5] "3747338-01-29" "3525922-06-12"

@eddelbuettel
Copy link
Owner

Fix your inputs. You may have missed the part where I said:

You cannot use single digit-months with the Boost parser.

and there is nothing I can do about his. Sorry.

@drolejoel
Copy link
Author

Then I mis-understood your instruction to use the useR argument. I was under the impression that by setting useR = TRUE it would not use the Boost parser and therefore it would instead go via code from R (and which would be able to handle single digit-months).

Thank you for your super-fast responses to my questions.

@eddelbuettel
Copy link
Owner

Good news - this now works in master (and hence the next release probably at the end of the month):

 R> a <- c("3/22/2013 0:00", "3/21/2012 0:00", "2/19/2014 0:00", "12/5/2013 0:00", 
+                "5/8/2013 0:00", "10/15/2010 0:00")
 R> library(anytime)
 R> anytime(a)
 [1] "2013-03-22 CDT" "2012-03-21 CDT" "2014-02-19 CST"
 [4] "2013-12-05 CST" "2013-05-08 CDT" "2010-10-15 CDT"
 R>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants