【发布时间】:2016-05-19 18:38:30
【问题描述】:
非常感谢您的帮助。 我有一个带有 ID 的表,列结果是 touchpoint_type。 当 ID 与前一个不同时,我给“C”,如果不是“I”。 这是我的代码: mydata_cce2$touchpoint_type
if (mydata_cce2$id_transaction[j] != mydata_cce2$id_transaction[j-1])
{ mydata_cce2$touchpoint_type[j] ="C"
}
else {
mydata_cce2$touchpoint_type[j] = "I"
}
}
This is the results that I should get:
id_transaction touchpoint_type
id_transaction touchpoint_type
1 68013539 C
2 68013539 I
3 68013539 I
4 68013702 C
5 68013738 C
6 68013738 I
这是我得到的错误:Error:inesperado '}' in "}"
Blockquote
【问题讨论】:
-
R 对你草率的格式感到不安。比较these two if-else statements。
标签: r if-statement conditional