考虑到ID
,我需要在稀疏数据帧上运行求和require(data.table)
sentEx = structure(list(abend = c(1, 1, 0, 0, 2), aber = c(0, 1, 0, 0,
0), über = c(1, 0, 0, 0, 0), überall = c(0, 0, 0, 0, 0), überlegt = c(0,
0, 0, 0, 0), ID = structure(c(1L, 1L, 2L, 2L, 2L), .Label = c("0019",
"0021"), class = "factor"), abgeandert = c(1, 1, 1, 0, 0), abgebildet = c(0,
0, 1, 1, 0), abgelegt = c(0, 0, 0, 0, 3)), .Names = c("abend",
"aber", "über", "überall", "überlegt", "ID", "abgeandert", "abgebildet",
"abgelegt"), row.names = c(1L, 2L, 16L, 17L, 18L), class = "data.frame")
sentEx # How it looks
abend aber über überall überlegt ID abgeandert abgebildet abgelegt
1 1 0 1 0 0 0019 1 0 0
2 1 1 0 0 0 0019 1 0 0
16 0 0 0 0 0 0021 1 1 0
17 0 0 0 0 0 0021 0 1 0
18 2 0 0 0 0 0021 0 0 3
没有“变音符号”它可以正常工作:
sentEx.dt <- data.table(sentEx[,-c(3,4,5)])[, lapply(.SD, sum), by=ID]
(sentExSum <- as.data.frame(sentEx.dt)) # Need again as dataframe, which looks like:
ID abend aber abgeandert abgebildet abgelegt
1 0019 2 1 2 0 0
2 0021 2 0 1 2 3
但是我得到了这个错误:
sentEx.dt <- data.table(sentEx)[, lapply(.SD, sum), by=ID]
# Error in gsum(`über`) : object 'über' not found
sentExSum <- as.data.frame(sentEx.dt)
一些额外的视频信息(因为问题似乎与系统有关 - 请参阅评论):
sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.9.2
loaded via a namespace (and not attached):
[1] plyr_1.8.1 Rcpp_0.11.0 reshape2_1.2.2 stringr_0.6.2 tools_3.0.2
还请求命令:
require(data.table); test.data.table()
Running C:/Users/Krohana/Documents/R/win-library/3.0/data.table/tests/tests.Rraw
Loading required package: reshape
Loading required package: hexbin
Loading required package: xts
Loading required package: bit64
Test 167.2 not run. If required call library(hexbin) first.
Don't know how to automatically pick scale for object of type ITime. Defaulting to continuous
Don't know how to automatically pick scale for object of type ITime. Defaulting to continuous
Tests 487 and 488 not run. If required call library(reshape) first.
Test 841 not run. If required call library(xts) first.
Tests 897-899 not run. If required call library(bit64) first.
All 1220 tests in inst/tests/tests.Rraw completed ok in 24.321sec on Sun Mar 02 17:57:26 2014 ts/tests.Rraw completed ok in 24.638sec on Sun Mar 02 17:55:45 2014
请求的命令2:
> Encoding(names(sentEx))
[1] "unknown" "unknown" "UTF-8" "UTF-8" "UTF-8" "unknown" "unknown" "unknown" "unknown"
> options(datatable.verbose=TRUE)
> options(datatable.verbose=TRUE); options(datatable.optimize=1L);
答案 0 :(得分:4)
我也无法复制。但是,Arun发现了另一个“找不到错误的对象”,我希望也是这个错误。
现在在v1.9.3中,提交1212.来自新闻:
o某些人可能会出现“找不到对象[名称]”错误 情况,特别是在上一次错误之后。报道 列名中的非ASCII字符,我们希望自己以来的红鲱鱼 data.table中的列名支持非ASCII字符。固定 实施和测试添加。
如果再次发生,请告诉我们。您的测试已逐字添加到测试套件中,谢谢。