I came across a peculiar behavior in the lubridate package: dmy(NA) error instead of just returning NA. This causes me problems when I want to convert a column with some elements that are NA and some date strings that usually convert without problems.
Here is a minimal example:
library(lubridate) df <- data.frame(ID=letters[1:5], Datum=c("01.01.1990", NA, "11.01.1990", NA, "01.02.1990")) df_copy <- df
To summarize, I have two questions: 1) Why does dmy (NA) not work? Based on most of the other functions, I would suggest that good programming practice is that each conversion (e.g. dmy ()) from NA returns NA again (like 2 + NA does)? If this behavior is intended, how do I convert a data.frame column that enables NA through the dmy() function?
r lubridate
Christoph_J
source share