Reputation: 509
I have a dataset that have a numeric date column. How can I convert 2017.31 in a numeric form to the date of "2017-4-22"?
Upvotes: 0
Views: 70
Reputation: 160437
That may be Apr 23, not the 22nd, but perhaps this is the right start:
vec <- 2017.31 as.POSIXct(paste(trunc(vec), trunc((vec %% 1) * 365)), format = "%Y %j", tz = "UTC") # [1] "2017-04-23 UTC"
The %j code is described in ?strptime.
%j
?strptime
Upvotes: 1