问题描述
使用.SD[.N]
选择行之后,由于元素数量不同,我无法转换列,然后是:
library(data.table)
dane = structure(list(DATA_CZAS = c("2010-08-20 10:24:03","2010-10-11 15:39:29","2010-12-10 13:40:31","2011-02-03 11:53:51","2011-02-03 11:57:06","2011-03-15 15:17:30","2011-03-29 09:41:57","2011-09-19 10:16:49","2011-11-24 15:54:34","2012-12-10 17:18:50","2012-12-10 17:30:11"
),KOD_ISIN = c("AT0000A00BF2","AT0000A00BF2","AT0000A00BF2"
),KURS = c(42.69,41.82,42.01,45.4,44.6,43.45,45.98,37.43,35.01,33.34,32.28),WOLUMEN = c(12L,50L,12L,78L,45L,24L,33L,60L,110L,1L,1L)),class = "data.frame",row.names = c(NA,-11L))
dane = data.table(dane)
dane$DATA_CZAS <- as.POSIXlt(dane$DATA_CZAS)
dane[,DATA_CZAS:=as.double(dane$DATA_CZAS) - as.double(dane$DATA_CZAS)%%(15*60)+15*60]
print(as.POSIXlt(dane$DATA_CZAS,origin = "1970-01-01",tz = "Europe/Warsaw"))
[1] "2010-08-20 10:30:00 CEST" "2010-10-11 15:45:00 CEST"
[3] "2010-12-10 13:45:00 CET" "2011-02-03 12:00:00 CET"
[5] "2011-02-03 12:00:00 CET" "2011-03-15 15:30:00 CET"
[7] "2011-03-29 09:45:00 CEST" "2011-09-19 10:30:00 CEST"
[9] "2011-11-24 16:00:00 CET" "2012-12-10 17:30:00 CET"
[11] "2012-12-10 17:45:00 CET"
dane <- dane[,.SD[.N],by=list(DATA_CZAS)]
> dane[,DATA_CZAS:=as.POSIXlt(DATA_CZAS,tz = "Europe/Warsaw")]
Błąd w poleceniu '`[.data.table`(dane,`:=`(DATA_CZAS,as.POSIXlt(DATA_CZAS,':
Supplied 11 items to be assigned to 10 items of column 'DATA_CZAS'. If you wish to 'recycle' the RHS please use rep() to make this intent clear to readers of your code.
> dane$DATA_CZAS <- as.POSIXlt(dane$DATA_CZAS,tz = "Europe/Warsaw")
Błąd w poleceniu 'set(x,j = name,value = value)':
Supplied 11 items to be assigned to 10 items of column 'DATA_CZAS'. If you wish to 'recycle' the RHS please use rep() to make this intent clear to readers of your code.
> packageVersion("data.table")
[1] ‘1.13.0’
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)