【发布时间】:2018-12-20 03:06:46
【问题描述】:
我有这个数据集:
a <- data.frame("session_id" = c(rep(1,10), rep(2,7), rep(3,2)),
"content" = c("A", "B", "C","open", "A", "J", "M", "K","exit", "D",
"open", "U", "T","quit", "I", "M" , "A", "Q", "M" ),
"type" = c("non-edit", "non-edit", "non-edit", "edit", "edit", "edit",
"edit", "edit", "edit", "non-edit", "edit", "edit", "edit",
"edit", "non-edit", "non-edit", "non-edit", "non-edit", "non-edit"))
我希望根据内容列将类型列分配给“非编辑”或“编辑”类型。当我们在内容中检测到“打开”直到“退出”或“退出”时,类型将是“编辑”。您可以在我提供的示例中看到该示例。
【问题讨论】:
标签: r dataframe dplyr grouping data-manipulation