You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/05/11 17:28:42 UTC

[GitHub] [arrow] jonkeane commented on pull request #13070: ARROW-15804: [R] Update as.Date() to support several tryFormats

jonkeane commented on PR #13070:
URL: https://github.com/apache/arrow/pull/13070#issuecomment-1124050785

   > Do you have any ideas on this? I"m struggling a bit to replicate the base behaviour (subsetting the column ...).
   
   What have you tried so far? This _will_ be tricky + it's totally possible that it is not feasible to emulate this behavior with the way we build these. 
   
   > On the returning NA. It depends. We don't align with the behaviour of as.Date() only when all formats fail to parse and optional = FALSE (which is the default) , in which case we align with as.Date(optional = TRUE). It's a decent, but again, not perfect overlap. 
   
   Since we have the option to either emit an `NA` or error on parsing fail, could we capture this behavior?  
   
   
   Tangentially, the example you use works, though it's a bit confusing IMO `%y` fails because it's year-without-century as opposed to `%Y`. And the NA at the beginning also made me think that was what you were relying on for failing the guessing, but that's doesn't actually make the parsing fail (which I got from reading the source of `as.Date.character`...). Here's a slightly more minimal | possibly less confusing example of that same phenomenon: 
   
   ```
   > x <- c("2022-01-01", "2022/01/01")
   > as.Date(x, tryFormats = c("%Y--", "%m--"), optional = FALSE)
   Error in charToDate(x) : 
     character string is not in a standard unambiguous format
   > as.Date(x, tryFormats = c("%Y--", "%m--"), optional = TRUE)
   [1] NA NA
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org