我有以下的列的數據:data.table外連接基於羣體中的R
CaseID, Time, Value.
的「時間」列的值不會在1.定期我嘗試添加缺少的除CaseID外的其餘列的時間值爲'NA'。
Case Value Time
1 100 07:52:00
1 110 07:53:00
1 120 07:55:00
2 10 08:35:00
2 11 08:36:00
2 12 08:38:00
所需的輸出:
Case Value Time
1 100 07:52:00
1 110 07:53:00
1 NA 07:54:00
1 120 07:55:00
2 10 08:35:00
2 11 08:36:00
2 NA 08:37:00
2 12 08:38:00
我試圖dt[CJ(unique(CaseID),seq(min(Time),max(Time),"min"))]
,但它提供了以下錯誤:
Error in vecseq(f__, len__, if (allow.cartesian || notjoin) NULL else as.integer(max(nrow(x), :
Join results in 9827315 rows; more than 9620640 = max(nrow(x),nrow(i)). Check for duplicate key values in i, each of which join to the same group in x over and over again. If that's ok, try including `j` and dropping `by` (by-without-by) so that j runs for each group to avoid the large allocation. If you are sure you wish to proceed, rerun with allow.cartesian=TRUE. Otherwise, please search for this error message in the FAQ, Wiki, Stack Overflow and datatable-help for advice.
我不能夠使它work..any幫助將不勝感激。
你想要的輸出是什麼? –
@DavidArenburg我已經編輯了我想要的輸出和我得到的錯誤 – UoU
的問題,你如何分配案例值? –