【发布时间】:2020-04-29 15:48:44
【问题描述】:
我有一个 A 列包含值的数据框:
**Channel**
Direct
Paid social
Organic social
我想要做的:创建一个名为 groupedChannel 的新列,其中 str_detect 在 A 列中搜索字符串以在 groupedChannel 中添加一个值。
Condition:
IF row in Column A matches regex "direct" THEN Column B value = "Direct" ELSE
IF row in Column B matches regex "social" THEN Column B value = "Social"
AFAIK,str_detect 将只返回 TRUE/FALSE。如何使用 TRUE/FALSE 在 B 列中分配值?
【问题讨论】:
标签: r