Re: [R] The assign function in R

From: Peter Dalgaard <>
Date: Thu, 19 Jun 2008 09:49:21 +0200

Duncan Murdoch wrote:
> Applejus wrote:
>> Hello,
>> I want to convert assign("a", b, where =1 ) from SPLUS to R.
>> Is it safe to assume that the equivalent of where=1 is pos=1 in R?
>> Thanks for help!
> Only a limited number of users here know what "where=1" means in
> S-PLUS. If one of those doesn't answer, you might want to explain
> that for those of us who have forgotten or who never knew.
Even some of those who should know may have forgotten by now... It is detailed in the Blue Book somewhere. As I recall it, the story is (or was?) that in S-PLUS objects are mostly on disk and the search path is a list of directories. Then there is a stack of evaluation frames plus two special frames, frame 0 and frame1. Frame 0 is permanent in the sense that it exists for the duration of the session, frame 1 exists during evaluation of expressions. Assignments to frame 1 were mostly done to overcome communication difficulties caused by the lack of lexical scope in S -- two different functions needing to work with the same temporary object would be the typical case.

I would conjecture that once the purpose of the assignment to frame 1 is understood, you can redesign the code so that it becomes much cleaner, possibly by using "<<-" semantics. For a quick port, what you need is some sort of temporary environment. Assigning to pos=1 is NOT the solution, because that is the global environment and you will (A) risk clobbering an existing variable of the same name and (B) litter your workspace with intermediate results.

   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (              FAX: (+45) 35327907

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 19 Jun 2008 - 08:45:41 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 Thu 19 Jun 2008 - 09:31:03 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive