I fairly new to R and I'm trying to wrap my head around this error. I've already consulted other questions regarding it and all of them imply that the error is thrown when there is a vector/list in the condition of an if statement, but that's not my case. I have only one condition:
if (dataset$scda == "I"){
a=1
}else if (dataset$scda == "A"){
a=2
}else{
a=0
}
And it throws the error
Error in if (dataset$scda == "I") { :
the condition has length > 1
Execution halted
I've tried to find out if the problem is caused by a vector in the condition, however, the output of
print(class(dataset$scda))
is
[1] "character"
So the standard answer I've found so far (e.g. "you have a vector in the condition") doesn't apply.