[R] Is there a way to make blocks of code independent from each other?

Peng Yu pengyu.ut at gmail.com
Mon Feb 1 02:56:16 CET 2010


I'm wondering if there is a way to make blocks of code independent
from each other. Please see the following example for what I mean.

x=1

## is there a way to make the following assignment not affect the above x?
## in C++, I can use {} to make the effect local. Is there an
equivalent construct in R?
x=3
<do something with the new value of x>
###

print(x) # I don't want the value of x change to 3.



More information about the R-help mailing list