根据另一个数据框的列和行号向数据框添加一列

时间:2019-10-17 21:08:53

标签: r dataframe

我现在有两个数据框,我想在dataframe raw.data列中的industry.fama.french.49列的基础上,在名为industry的数据框section.pos中添加一列,并且它处于条件下doc_id列是raw.data的行号,这意味着在section.pos中doc_id = 1的所有行在新列行业中都应具有2Food值。

我尝试的代码是:

section.1.pos $ industry <-raw.data $ industry.fama.french.49 [as.numeric(row.names(raw.data))== section.1.pos $ doc_id]

我应该如何更改?

dataframe section.1.pos

dataframe raw.data

0 个答案:

没有答案