У меня есть набор данных df1
.

Я хотел бы заменить каждое вхождение «Один + один», «Два; один» и т. Д. На некоторые числа, как показано в таблице поиска df2
.

Желаемый вывод:

Есть идеи, как это сделать? Это продолжение моего первоначального вопроса
Как заменить строковые значения в столбце на основе справочной таблицы
Я попробовал следующее, но это не работает. Заранее спасибо!
df1$New <- gsubfn::gsubfn("[A-z]+,;", as.list(setNames(df2$Node,df2$Label)), df1$Node)
Данные:
df1 <- data.frame(ID = 1:5, Node = c("One + one > Two ; one > Three ; two", "One + two > Two ; two > Three ; one", "One + one > Two ; two > Three ; one", "One + two > Two ; one > Three ; two", "One + one > Two ; two > Three ; two"), stringsAsFactors = FALSE)
df2 <- data.frame(Label = c("One + one", "One + two", "Two ; one", "Two ; two", "Three ; one", "Three ; two"), Node = c("1.1", "1.2", "2.1", "2.2", "3.1", "3.2"), stringsAsFactors = FALSE)
ОБНОВЛЕННЫЕ ДАННЫЕ:
df1 <- data.frame(ID = 1:5, Node = c("AO Ales + Bitter > Brown and Stout > Premium && Super Premium",
"Lager > Dry, Premium Strength, Style, Traditional > Mainstream & Value",
"AO Ales + Bitter > Dry, Premium Strength, Style, Traditional > Mainstream & Value",
"Lager > Brown and Stout > Dry, Premium Strength, Style, Traditional",
"AO Ales + Bitter > Dry, Premium Strength, Style, Traditional > Premium && Super Premium"), stringsAsFactors = FALSE)
df2 <- data.frame(Label = c("AO Ales + Bitter",
+ "Lager",
+ "Brown and Stout",
+ "Dry, Premium Strength, Style, Traditional",
+ "Mainstream & Value",
+ "Premium && Super Premium"
+ ), Node = c("1.1", "1.2", "2.1", "2.2", "3.1", "3.2"), stringsAsFactors = FALSE)