Reputation: 735
With a data set imported from MS Excel 2010, similar to df
which is:
x0 xx d1 d2
2014-04-29 16189 1944-04-27 1944-04-29
2014-04-29 16189 1944-04-27 1944-04-29
2014-04-29 16189 1944-04-27 1944-04-29
2014-04-29 16189 1944-04-27 1944-04-29
2014-04-29 16189 1944-04-27 1944-04-29
2014-04-28 16188 1944-04-26 1944-04-28
2014-04-29 16189 1944-04-27 1944-04-29
2014-04-24 16184 1944-04-22 1944-04-24
2014-04-29 16189 1944-04-27 1944-04-29
2014-04-29 16189 1944-04-27 1944-04-29
where xx
is the number of days since 1/1/1900 stored in Excel, and
df$d1 = as.Date(df$xx, origin = "1899-12-30")
df$d2 = as.Date(df$xx, origin = "1900-01-01")
as suggested in R Documentation. x0
is the correct corresponding date generated manually to show what I want to obtain.
How can I convert df$xx
to R's Date format? With those suggestions, I am not getting the correct year.
Upvotes: 0
Views: 262
Reputation: 66834
It seems that your values are referencing the Unix Epoch:
as.Date(16189,origin="1970-01-01")
[1] "2014-04-29"
Upvotes: 1