I'm puzzled by my example below. This answer might contain the key for me, but I'm missing it. When I run as.Date("1900-01-01")
R prints something that looks just like the input:
> as.Date("1920-01-01")
[1] "1920-01-01"
I had hoped to check that inputs were "Dates" and coerce them to be if they were character
, and so I wrote this very simple function to learn what was going on
check_date <- function(x){
ifelse(class(x)=="Date"
, x
, as.Date(x))
}
But now it seems like I'm getting a numeric
value back out:
cdOut <- check_date("1920-01-01")
> cdOut
[1] -18263
What is happening here?