[R] Putting all elementes of the list in an enviorment of a function
Ales Ziberna
aleszib at gmail.com
Tue Aug 2 11:57:27 CEST 2005
I apologize, it seams did not interpret your first mail corectly!
Everything works now!
Thank you again!
Ales Ziberna
----- Original Message -----
From: "Prof Brian Ripley" <ripley at stats.ox.ac.uk>
To: "Ales Ziberna" <aleszib at gmail.com>
Cc: "R-help" <r-help at stat.math.ethz.ch>
Sent: Tuesday, August 02, 2005 11:25 AM
Subject: Re: [R] Putting all elementes of the list in an enviorment of a
function
> On Tue, 2 Aug 2005, Ales Ziberna wrote:
>
>> Thank you!
>>
>> However, this does not do exacty what I want. I would like somehow to
>> modify only the function second.
>
> What happened when you tried my suggestion as
>
> second <- function(l, c) with(l, a + b + c)
>
> ? It does work for me.
>
>> BTW, I used "list" only to create a "list", it is not one of my
>> functions.
>
> You used it as a variable within second()!
>
>
>> Thanks again,
>> Ales Ziberna
>>
>> ----- Original Message ----- From: "Prof Brian Ripley"
>> <ripley at stats.ox.ac.uk>
>> To: "Ales Ziberna" <ales.ziberna at guest.arnes.si>
>> Cc: "R-help" <r-help at stat.math.ethz.ch>
>> Sent: Tuesday, August 02, 2005 10:35 AM
>> Subject: Re: [R] Putting all elementes of the list in an enviorment of a
>> function
>>
>>
>>> ?with will help you.
>>>
>>> I would avoid using 'list' as a function name, as it will confuse people
>>> and might confuse R too.
>>>
>>> On Tue, 2 Aug 2005, [iso-8859-2] Alea }iberna wrote:
>>>
>>>> Hello!
>>>>
>>>> I have two functions.
>>>>
>>>> The first one prepares the arguments for the second one. What is the
>>>> best
>>>> way to put all resoults of the first one into the second one? I tried
>>>> attach, however the object in the "main" enviorment have a priority
>>>> over the
>>>> ones in list. An example is at the end.
>>>>
>>>> Thanks in advance for any suggestions!
>>>> Ales Ziberna
>>>>
>>>> For example - I would like to use just "a" instead of "list$a" in
>>>> fuction
>>>> "second"
>>>>
>>>> first<-function(a,b){
>>>> if(length(a)!=1) a <- a[1]
>>>> if(length(b)!=1) b <- b[1]
>>>> list(a=a,b=b)
>>>> }
>>>>
>>>> second<-function(list,c){
>>>> list$a + list$b + c
>>>> }
>>>>
>>>> a<-c(2,3)
>>>> b<-4:64
>>>> c<-5
>>>>
>>>> res<-first(a,b)
>>>> second(res,c)
>>>
>>> --
>>> Brian D. Ripley, ripley at stats.ox.ac.uk
>>> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
>>> University of Oxford, Tel: +44 1865 272861 (self)
>>> 1 South Parks Road, +44 1865 272866 (PA)
>>> Oxford OX1 3TG, UK Fax: +44 1865 272595
>>>
>>> ______________________________________________
>>> R-help at stat.math.ethz.ch mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide!
>>> http://www.R-project.org/posting-guide.html
>>
>>
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list