-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Not sure but I assume below should work. Field time_code is unique Date.
Latest master currently crash R session in the below case:
library(data.table)
DT <- data.table(
time_code = structure(c(15436, 15437, 15438, 15439, 15440), class = "Date"),
value = c(712242.20376462, 608841.4513506, 182544.2945119, 872201.29650086, 352442.92207062)
)
DT[, c("value_lead_2") := shift(value, n=2, fill=NA, type="lead", give.names=FALSE), by=c("time_code")]
session
R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_DK.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=C
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.9.5
loaded via a namespace (and not attached):
[1] bitops_1.0-6 chron_2.3-45 devtools_1.6.1 httr_0.6.1 RCurl_1.95-4.5 stringr_0.6.2 tools_3.1.2