Skip to content

Assignment operators (was [R] modifying a vector)

2 messages · Brian Ripley, Frank E Harrell Jr

#
On Sun, 30 Jun 2002, Frank E Harrell Jr wrote:

            
caused by "=" (e.g., mistyping sex=='male' as sex='male') that was not
envisioned by the developers.  -Frank Harrell

Frank,

Was that actually in R (where very few people use =)?  Unlike S4, = is not
a general-purpose assignment operator, and this sort of thing *was*
`envisioned by the developers'.  For example, if(sex = "male") is a syntax
error in R.  (Some more insidious ones, such as using assignment in the
a function call, are also disallowed.)

If there is evidence that this is regularly causing trouble we would want
to re-consider its scope, but the availability of `=' is hardly publicised
(and not even the editor of the Programmer's Niche remembered about it).

Brian

(Moved to R-devel, as maybe R-help should be spared this source of
confusion.)
#
On Sun, 30 Jun 2002 18:57:38 +0100 (BST)
ripley@stats.ox.ac.uk wrote:

            
It was probably S-Plus.  I have trouble keeping S-Plus and R separate sometimes.
I hope that R also provides safeguards about "=" when it appears in an argument to a function.
Sure.  Thanks Brian  -Frank