[R-sig-teaching] The pedagogy of the assignment operator

Sebastian P. Luque spluque at gmail.com
Tue Oct 26 22:17:22 CEST 2010


On Wed, 27 Oct 2010 08:10:41 +1300,
Murray Jorgensen <maj at waikato.ac.nz> wrote:

> Greetings all, in my own R code I have used various forms of the R
> assignment operator at different times in my life. There are arguments
> for and against each choice.

> A question I would like this sig is whether there are any specifically
> teaching reasons for preferring one form over another?

> A second question, mainly to clarify the first, is whether different
> forms might be preferred for different types of student?

> Awaiting responses with interest

Personally I find the most compelling reason to get into the habit of
using "<-" for assignments as early as possible is that it has a single
meaning, whereas "=" has two different meanings as others have pointed
out.  It makes code a lot cleaner and easier to read because assignments
readily stand-out from parts where a value is being given to an
argument.  Although it might be easier for some new users to read and
type "=" for assignments, it blurs the distinction between the two
different meanings for "=".  Because these different meanings depend on
the context, that's one more thing for a user to keep in mind.

-- 
Seb




More information about the R-sig-teaching mailing list