Spencer Graves <[EMAIL PROTECTED]> writes: > 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 error > first replaces column "a" of DF with the trivial vector 1 (of length > 1), and then interprets that as a logical, which evaluates as TRUE. > Unless the "if" statement otherwise generates an error, I must restore > column "a" from somewhere before I can continue.
Eh? > a <- list(x=2) > if (a$x = 1) 5 Error: syntax error I think you're referring to another R-like language.... > In addition to specifying function arguments, I also use > "=" to specify named components of a list or a vector. That works > fine for me. It's only the accidental use of "=" when I mean "==" that > creates problems. (Actually, that's the same thing. list() and c() are function calls like (almost) everything else.) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
