0
試圖將多個變量合併爲二分變量。我想使用OR運算符「|」來根據原始變量中的條件值分配新值,IfElse with OR運算符
數據幀c具有與值 「原因」 一欄( 「回答」, 「不能談」, 「called_back」, 「懸而未決」, 「語音郵件」)
# Collapse several responses into one value
c$answered <- if(c$reason == "answered" |
"couldNotTalk" |
"called_back")
{c$answer == "answered"}
else {c$unanswer == "not answered"}
這不是工作,但下面是(即使它是有效的):
"Answered" -> c$answer[c$reason == "answered"]
"Answered" -> c$answer[c$reason == "couldNotTalk"]
"Answered" -> c$answer[c$reason == "called_back"]
感謝。第二個是我想要做的,所以是完美的。 – Jebediah15 2015-02-23 17:58:29