将包含日期列的data.tables与rbindlist合并

时间:2017-10-11 19:24:17

标签: r data.table

以下是两个data.table个对象:

a <- data.table(v1=today(), v2=seq(1, 5))
b <- data.table(v2=seq(6, 10))

当我想将它们与rbindlist函数结合使用时,如果list的第一个元素是a,一切顺利,但如果第一个元素是list,我会收到错误消息我的b> rbindlist(list(a, b), fill=TRUE) v1 v2 1: 2017-10-11 1 2: 2017-10-11 2 3: 2017-10-11 3 4: 2017-10-11 4 5: 2017-10-11 5 6: <NA> 6 7: <NA> 7 8: <NA> 8 9: <NA> 9 10: <NA> 10 > rbindlist(list(b, a), fill=TRUE) Error in rbindlist(list(b, a), fill = TRUE) : Class attributes at column 2 of input list at position 2 does not match with column 2 of input list at position 1. Coercion of objects of class 'factor' alone is handled internally by rbind/rbindlist at the moment.

select t.person_id,
sum(case when t.email_event_type = 'DELIVER' then 1 else 0) deliver_count, 
sum(case when t.email_event_type = 'OPEN' then 1 else 0) open_count, 
sum(case when t.email_event_type = 'CLICK' then 1 else 0) click_count
from <your_table_name> t
group by t.person_id

我想我会得到完全相同的结果,除了第1行到第5行和第6行到第10行可以互换。

有人能解释我为什么吗?有没有办法解决这个问题?

0 个答案:

没有答案