R-alpha: assignment scoping

Luke Tierney (luke@stat.umn.edu)
Tue, 28 May 1996 05:39:53 -0500 (CDT)


From: Luke Tierney <luke@stat.umn.edu>
Message-Id: <9605281039.AA07296@nokomis.stat.umn.edu>
Subject: R-alpha: assignment scoping
To: r-testers@stat.math.ethz.ch
Date: Tue, 28 May 1996 05:39:53 -0500 (CDT)

Assignment to subscripts is interpreted a bit differently in R and
S. In S, it creates a new local variable if one does not exist; in R
it doesn't.

-------------------------------------------------------------------------------
S-PLUS : Copyright (c) 1988, 1995 MathSoft, Inc.
S : Copyright AT&T.
Version 3.3 Release 1 for HP Series 700, HP-UX 9.x : 1995
Working data will be in .Data
> x<-c(1,2)
> f<-function() {x[1]<-3;x}
> f()
[1] 3 2
> x
[1] 1 2
-------------------------------------------------------------------------------
R : Copyright (c) 1996, Robert Gentleman and Ross Ihaka
Version 0.6, (Released: May 17, 1996)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type "license()" for details.

> x<-c(1,2)
> f<-function() {x[1]<-3;x}
> f()
[1] 3 2
> x
[1] 3 2
-------------------------------------------------------------------------------

luke
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-