Re: [R] The assign function in R

From: Applejus <ielkhoury_at_gmail.com>
Date: Thu, 19 Jun 2008 12:45:55 -0700 (PDT)

Thanks all for your help!

Peter Dalgaard wrote:

> 
> Prof Brian Ripley wrote:

>> For the record, frame=1 and where=1 are not the same thing (whereas
>> frame=0 and where=0 are both the session database): assign() in S has
>> both 'frame' and 'where' arguments.
>>
> Drats... I stand corrected. Thanks to Brian for clearing this up.
> 
>     -p

>> where=1 is the first database on the search() path, and is roughly
>> equivalent to the workspace (although you can attach databases ahead
>> of the working database in S(-PLUS), people who write code like
>> where=1 often do not know that).
>>
>> In S(-PLUS) there is a working database aka chapter, which is the
>> nearest equivalent to the R workspace but is (conceptually) stored on
>> disc and so permanent. It is like running R with --restore --save.
>> Unless some other database is attached at pos=1, the working database
>> is at where=1.
>>
>> The Blue Book contains the help page for assign() in S ca 1988, and
>> apart from what where=0 means (which may well be a later addition) the
>> information is all there.
>>
>> On Thu, 19 Jun 2008, Peter Dalgaard wrote:
>>
>>> 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
>>> ~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk) FAX: (+45) 35327907
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
> 
> 
> -- 
>    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
> ~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)              FAX: (+45) 35327907
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/The-assign-function-in-R-tp17918416p18016661.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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 Thu 19 Jun 2008 - 20:38:14 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 - 21:31:34 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