Spencer Graves <[EMAIL PROTECTED]> wrote:
A common, punishing error for me, with DF being a data frame, is the
following:
if(DF$a = 1) ...
where I intended to write "if(DF$a == 1)...".
This is a syntax error in R.
> d <- data.frame(a=2,b=3,c=4)
> if (d$a=1) cat("foo!")
Error: syntax error
If I've understood the R documentation correctly, "=" is only allowed
as a synonym for "<-" at "statement" level.
Of course, that's one more reason not to use "=" when you DO want
assignment; "<-" has no such restriction.
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help