Skip to content

[R-Forge #5252] rbindlist should support expression columns #546

Description

@arunsrinivasan

Submitted by: Matt Dowle; Assigned to: Nobody; R-Forge link

From Jan Górecki on email :

library(data.table)
# desired solution
a <- data.table(c1 = 1, c2 = 'asd', c3 = expression(as.character(Sys.time())))
b <- data.table(c1 = 3, c2 = 'qwe', c3 = expression(as.character(Sys.time()+5)))
dt <- rbind(a,b)
#Error in rbindlist(allargs) : Unsupported column type 'expression'
dt <- rbindlist(list(a,b))
#Error in rbindlist(list(a, b)) : Unsupported column type 'expression'

# current workaround
a <- data.table(c1 = 1, c2 = 'asd', c3 =
list(expression(as.character(Sys.time()))))
b <- data.table(c1 = 3, c2 = 'qwe', c3 =
list(expression(as.character(Sys.time()+5))))
dt <- rbind(a,b)
dt <- rbindlist(list(a,b))
# both ok, but the desired solution would be:
dt[,list(c1,c2,eval(c3))]
# and it will not produce expected results because of previous workaround
# another workaround must be done:
dt[,list(c1,c2,lapply(c3,eval))]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions