【发布时间】:2019-06-26 18:34:29
【问题描述】:
我希望你能在这里帮助我。我找到了很多基本的重新编码答案,但没有一个可以适应我的问题。 问题是:对于所有行,我想将列 Level_eng_1 设置为该行的 parent_concept 列与 ID 列匹配的每一行的列verb_e 的值。
我尝试调整 stackoverflow 上现有的众多解决方案,但没有成功。
这是数据。
structure(list(ID = c(1, 2, 3, 11, 12, 13, 14, 16, 20, 21, 22,
23, 24, 25, 30, 31, 32, 33, 34), Parent_Concept = c(0L, 0L, 0L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L
), verb_e = c("act", "change", "move", "support", "regulate",
"interact", "structure", "communicate", "time", "make", "decrease",
"increase", "modify", "orientate", "motion", "inhibit", "bring_together",
"separate", "transmit"), Level_eng_1 = c(NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA, 19L), class = "data.frame")
想要的输出是:
structure(list(ID = c(1, 2, 3, 11, 12, 13, 14, 16, 20, 21, 22,
23, 24, 25, 30, 31, 32, 33, 34), Parent_Concept = c(0L, 0L, 0L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L
), verb_e = c("act", "change", "move", "support", "regulate",
"interact", "structure", "communicate", "time", "make", "decrease",
"increase", "modify", "orientate", "motion", "inhibit", "bring_together",
"separate", "transmit"), Level_eng_1 = c("act", "change", "move",
"act", "act", "act", "act", "act", "change", "change", "change",
"change", "change", "change", "move", "move", "move", "move",
"move")), row.names = c(NA, 19L), class = "data.frame")
感谢您的帮助!
【问题讨论】:
-
0 的值不匹配
标签: r dataframe datatable recode