Skip to content
Prev 243800 / 398506 Next

using ``<-'' in function argument

On Dec 2, 2010, at 10:47 PM, Erik Iverson wrote:

            
Certain functions (so-called "primitive" functions)  are entirely  
driven by positional matching, although matrix is not one of those  
functions. Erik is telling you that your use of ncol<-4 got evaluated  
to 4 and that the name of the resulting object was ignored, howevert  
the value of the operation was passed on to matrix which used  
positional matching since "=" was not used. Usually the problem facing  
newbies is that they want to save keystrokes and so use "=" for  
assignment (also a potential pitfall although not as likely to mess  
you up as the choice to use the two-keystroke path for argument  
assignment).

  "<-" is really a function and returns a value in addition to having  
a side-effect of assigning a value to an object.

 > y <- eval(x<-4)
 > y
[1] 4
David Winsemius, MD
West Hartford, CT