dragosmg commented on PR #13070:
URL: https://github.com/apache/arrow/pull/13070#issuecomment-1123968811
> Like I mention with the test addition, I suspect coalesce isn't quite the
right behavior here. As for returning NA: is that the behavior of the function
we are binding? If so, that's great + good. If not, we should think if we can
fix that.
I agree with you that `coalesce()` doesn't seem to be the right behaviour
(i.e. not giving us _perfect_ overlap with `base::as.Date()`). Do you have any
ideas on this? I can't replicate the base behaviour (subsetting the column ...).
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.
``` r
x <- c(NA, "2022-01-01", "2022/01/01")
as.Date(x, tryFormats = c("%y-%m-%d", "%y/%m/%d"), optional = FALSE) #
default
#> Error in charToDate(x): character string is not in a standard unambiguous
format
as.Date(x, tryFormats = c("%y-%m-%d", "%y/%m/%d"), optional = TRUE)
#> [1] NA NA NA
```
<sup>Created on 2022-05-11 by the [reprex
package](https://reprex.tidyverse.org) (v2.0.1)</sup>
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]