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

From: Giles Crane <gilescrane_at_verizon.net>
Date: Sat, 12 Mar 2011 16:32:35 -0500

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

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 12 Mar 2011 - 21:36:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 Mar 2011 - 21:40:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive