I have the following code:
a=2
if (length(a)>1){
b<<-rowSums(c[,-(1:2)][,c(T,F)]) }
else {b<<-sum(c[seq(3,length(x),2)]) }
I get the following error:
Error: unexpected 'else' in " else"
I have no idea why I am getting this message. Any ideas?
In the R definition:
(R Language Definition)
So, the ‘else’ must me in the same line as ‘}’. Either
or
but is still a bad code/identation pattern. I’d try something like
to avoid further mistakes, or the suggested ‘ifelse’ function.