[R] Behavior of assignment within system.time()

Giles Crane gilescrane at verizon.net
Sat Mar 12 22:32:35 CET 2011


There are instances when assignment
should be indicated by "<-" rather than "=".
One example is the function Sys.time().

sytem.time( x=1:10000)   # x is interpreted as an argument and is an 
error here.

system.time( x<-1:1000)  # times the creation of x with numbers 1 to 10000

However, grouping the statement with curly brackets
also gives the correct system time.

system.time(   { x=1:10000}  )   # times the statement correctly

Having fun with R,
Giles Crane



More information about the R-help mailing list