从 R 中的 table 过滤掉条目

Filtering out entries from a table in R

我正在分析 R 中的 table,它有 5 列:名称、种子、权重、优先级和等级(我们称此变量为 fulltable).

我还从另一个 table 中分离出一个列 ('name') 我使用的是:

candidates <- othertable$name 

我现在想做的是从 fulltable 中提取所有条目,其中 fulltable$name 匹配 candidates 中的任何条目。对我来说重要的是找出两者:

  1. 候选人的哪些参赛作品完整table

  1. 这些条目的权重、优先级和排名是多少。

本质上,我想提取每个点的整行,其中两个 table 的列之间存在匹配项。

当我使用像 intersect(fulltable$name, candidates) 这样的函数时,我得到一个字符串,显示名称列的重叠(回答了我的问题 1),但没有其他关键信息(即没有权重、优先级、或排名信息)。

非常感谢任何帮助!

如果我没看错,您可能会对以下内容感兴趣:

subdata <- fulldata[match(candidates, fulldata$name),]

例如:

假设您有一个这样的数据框 fulltable

 fulltable
    Namen Value1 Value2
1     max      1      1
2 Andreas      2      2
3   Achim      3      3
4   micha      4      4
5  Robert      5      5
6    Ralf      6      6
7   manny      7      7

并希望提取以下名称:

> candidates
[1] "max"   "micha" "manny"

然后下面这行代码的结果是:

fulltable[match(candidates, fulltable$Namen),]
  Namen Value1 Value2
1   max      1      1
4 micha      4      4
7 manny      7      7