如何将子集data.table R

时间:2018-12-01 19:41:28

标签: r data.table

我有电影类型的数据库。我想让我的数据库中只有一部电影。现在看起来像:

                             name  genres
 1:             #1 Cheerleader Camp  Comedy
 2:                #1 Serial Killer  Horror
 3: #1 at the Apocalypse Box Office  Comedy
 4: #1 at the Apocalypse Box Office      Fi
 5: #1 at the Apocalypse Box Office   Short

我想拥有的是:

                             name  genres
 1:             #1 Cheerleader Camp  Comedy
 2:                #1 Serial Killer  Horror
 3: #1 at the Apocalypse Box Office  Comedy Short Fi

我尝试了data[, genresALL := cat(genres), by = name], 'data2 <-data [,。(cat(genres)),by = name]',但它不起作用。第二个选项给出以下错误:

  

[.data.table中的ComedyError(数据,..(cat(genres)),按=名称):
  j的第一组结果的第1列为NULL。我们依靠   第一个结果的列类型,以决定预期的类型   其余组(并要求保持一致性)。 NULL列是   以后的组可以接受(并且被NA替换为NA)   适当的类型并进行了回收),但不是第一次使用。请使用   而是输入空向量,例如integer()或numeric()。

0 个答案:

没有答案
相关问题