[R] unexpected 'else' in " else"
Jinsong Zhao
j@zh@o @end|ng |rom ye@h@net
Fri Oct 21 11:29:15 CEST 2022
Hi there,
The following code would cause R error:
> w <- 1:5
> r <- 1:5
> if (is.matrix(r))
+ r[w != 0, , drop = FALSE]
> else r[w != 0]
Error: unexpected 'else' in " else"
However, the code:
if (is.matrix(r))
r[w != 0, , drop = FALSE]
else r[w != 0]
is extracted from stats::weighted.residuals.
My question is why the code in the function does not cause error?
Best,
Jinsong
More information about the R-help
mailing list