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

Simon Blomberg s.blomberg1 at uq.edu.au
Wed Oct 27 02:51:16 CEST 2010


I like the Venables and Ripley reasoning around the assignment 
character: use different characters for assignment in different 
environments. So you have = for assignment inside function calls, <- for 
assignment in the current environment, and <<- for assignment in the 
global environment.

Cheers,

Simon.

On 27/10/10 10:41, Murray Jorgensen wrote:
> I can see that I am going to have to set a little context because I 
> wanted to anchor the discussion in the teaching of statistics, and not 
> of R as a language. I think the issues are different in the two. One 
> big problem in the former is that symbols can engender fear in the 
> students.
>
> A few years ago I was taken off the teaching of a large first year 
> business statistics course. The clinching incident in this decision 
> mentioned by my then chairperson was the use ( in a side-discussion ) 
> of the mathematical summation sign ( upper-case Greek sigma ).  I 
> don't think my chairperson was wrong. In the context of that course 
> what I should have done was illustrate my point with a column of data 
> in an Excel spreadsheet.
>
> If \Sigma upsets business students with its suggestion of abstract 
> mathematics, I think many other statistics students find <- somewhat 
> suggestive of abstract logic or theoretical computer science, 
> favourite subjects of an epsilonic proportion of the large classes I 
> used to teach.
>
> I teach smaller classes now and my students come to me with previous 
> exposure to Minitab which uses = for assignment. I use = both to avoid 
> any of the symbol-fear that I spoke of, and also because they are used 
> to how assignment works in Minitab. (For maybe half of the students, 
> Minitab would be the only computer language that they would have met.)
>
> I will come clean and admit that I have another reason for not liking R.
> The symbol <- suggests the right-to-left direction of the assignment 
> strongly and appropriately. But I read from left-to-right and I get 
> startled by an arrow coming at me from the unseen future and feel a 
> second or two of cognitive dissonance.
>
> I actually rather like the right-pointing -> assignment as the 
> directions of reading and of computation agree. It would be a bit 
> idiosyncratic to use it in code though. I find it useful in 
> interactive R when I have typed and evaluated a complex expression and 
> realise that I really should have assigned it to something. After the 
> up-arrow key -> lets me do the needed assignment on the right of the 
> expression.
>
> Murray
>
> On 27/10/2010 12:59 p.m., Gabor Grothendieck wrote:
>> On Tue, Oct 26, 2010 at 3:10 PM, 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  -  Murray
>>
>> <- is less error prone so you always want to use that.  It might be
>> argued that there are only a few cases where it matters but if you run
>> into one of those cases you will be sorry you did not standardize on
>> using<- .
>>
>
>

-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.




More information about the R-sig-teaching mailing list