Skip to content

IDate storage mode not preserved in data frames #2008

Closed
@rmcgehee

Description

@rmcgehee

Hi,
To save space, I've been using IDate within my data frames (not data tables) to save space. Maybe this is a user bug right here, if IDate isn't meant to be used outside of data.tables, but I'll continue.

Seems that rbind() does not preserve the integer storage mode of IDate inside of data.frames, which causes problems when using IDate arithmetic. Instead, rbind coerces IDate into storage.mode double. My code has worked perfectly for a while. I only started seeing errors after updating to the latest data.table 1.10.0 and R 3.3.2. However, I'm not sure if the coercion to double didn't happen in the earlier versions, or just that it wasn't checked before.

Here's an example:

x <- data.frame(date=as.IDate(Sys.Date()))
y <- rbind(x, x)
x$date -1
# [1] "2017-01-29"
y$date -1

Error in -.IDate(y$date, 1) :
Internal error: storage mode of IDate is somehow no longer integer

storage.mode(x$date)
# [1] "integer"
storage.mode(y$date)
# [1] "double"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions