Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 抗子集设置的magic data.table_R_Data.table - Fatal编程技术网

R 抗子集设置的magic data.table

R 抗子集设置的magic data.table,r,data.table,R,Data.table,我的一位同事发送了以下数据。表(来自CRAN的1.9.4版): 但由于某些原因,它不能被类型==“current”作为子集: > w[type=='current',] Empty data.table (0 rows) of 2 cols: type,value 使用get函数可解决此问题: > w[get('type')=='current',] type value 1: current 10 从data.table中删除索引的操作如下: x <-

我的一位同事发送了以下
数据。表
(来自CRAN的1.9.4版):

但由于某些原因,它不能被
类型==“current”
作为子集:

> w[type=='current',]
Empty data.table (0 rows) of 2 cols: type,value
使用
get
函数可解决此问题:

> w[get('type')=='current',]
      type value
1: current    10
从data.table中删除索引的操作如下:

x <- structure(
  list(
    type = c("current", "prior"),
    value = c(10, 20)
  ), 
  class = c("data.table", "data.frame")
)
> x
      type value
1: current    10
2:   prior    20
x
类型值
1:当前10
2:20岁以前

data.table上的“index”属性是什么?我如何防止将来创建它?我知道我的同事并非有意创建此索引,而是在联接或子集操作过程中,此data.table以某种方式获得了这种神奇的特性。

index
data.table使用的一种内部结构,旨在加速重复的索引操作。在1.9.4中,它曾经是一个bug,但是大多数bug都在1.9.5中被消除了。也可以通过
选项(datatable.auto.index=FALSE)
禁用它。投票结束问题。这已在
数据中修复。表
v>=1.9.5。投票也要结束。是的,但是对于标题中带有“魔力”的问题,+1…@BenBolker我也尝试添加[magic]标签。
> w[get('type')=='current',]
      type value
1: current    10
x <- structure(
  list(
    type = c("current", "prior"),
    value = c(10, 20)
  ), 
  class = c("data.table", "data.frame")
)
> x
      type value
1: current    10
2:   prior    20