-
Notifications
You must be signed in to change notification settings - Fork 985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
as.Date.IDate won't change the class if xts package loaded #1500
Comments
I see different output:
and the same with 64-bit ( I didn't update to the latest, latest 1.9.7, but if you have done, then at least this might be helpful in pinpointing where/when it broke. |
Just tested latest data.table and I can confirm it is working as expected: library(data.table)
id = as.IDate("2016-01-15")
class(id)
#[1] "IDate" "Date"
class(as.Date(id))
#[1] "Date"
class(as.Date(as.integer(id)))
#Error in as.Date.numeric(as.integer(id)) : 'origin' must be supplied
sessionInfo()
#R version 3.2.3 (2015-12-10)
#Platform: x86_64-pc-linux-gnu (64-bit)
#Running under: Ubuntu 14.04.3 LTS
#
#locale:
# [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8 #LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8
# [6] LC_MESSAGES=en_GB.UTF-8 LC_PAPER=en_GB.UTF-8 LC_NAME=C #LC_ADDRESS=C LC_TELEPHONE=C
#[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
#
#attached base packages:
#[1] stats graphics grDevices utils datasets methods base
#
#other attached packages:
#[1] data.table_1.9.7
#
#loaded via a namespace (and not attached):
#[1] tools_3.2.3 chron_2.3-47 I also tested with R 3.2.2 and data.table 1.9.6 and works fine. |
@franknarf1 reproduce issue with the following library(data.table)
library(xts)
dt = data.table(date = as.IDate("2016-01-15"))
dt[, date := as.Date(date)]
class(dt$date)
#[1] "IDate" "Date" while that works as expected: library(data.table)
dt = data.table(date = as.IDate("2016-01-15"))
dt[, date := as.Date(date)]
class(dt$date)
#[1] "Date" |
Yes, I also see what you're seeing. |
library(data.table)
x = as.IDate("2016-01-15")
class(as.Date(x))
#[1] "Date"
library(zoo)
class(as.Date(x))
#[1] "IDate" "Date"
class(data.table:::as.Date.IDate(x))
#[1] "Date" |
To convert your IDate into Date you currently need to go through
as.integer
.when resolved update this SO.
The text was updated successfully, but these errors were encountered: