Thanks Rolf, that was a mistake.
Brilliant, I think with() is what I'm looking for, thanks a lot!
cheers,
alastair
Rolf Turner-3 wrote
> On 26/11/12 14:24, Ally wrote:
>> I'd like to pass a list object created by one function as an argument of
>> another function. once inside the second func
On 26/11/12 14:24, Ally wrote:
I'd like to pass a list object created by one function as an argument of
another function. once inside the second function, I'd like to break the
list up to it's individual elements, each then identifiable by the 'names'
of the list.
The list looks something like
I should have been clearer, the function I supplied is just a toy example, I
actually have lots more elements, each with different classes, and need to
do more complex things than just summation. The main reason I'm interested
in this is to avoid having to keep adding an assignment like x<-lst$x e
lists between functions
I'd like to pass a list object created by one function as an argument of
another function. once inside the second function, I'd like to break the
list up to it's individual elements, each then identifiable by the 'names'
of the list.
The list
Wrong -- I forgot to use the parameter name
do_something<-function(L){
L$a+L$b+L$df+L$g
}
do_something(lst)
On Sun, Nov 25, 2012 at 9:02 PM, jim holtman wrote:
> Just reference the objects in the list:
>
> do_something<-function(L){
>
> lst$a+lst$b+lst$df+lst$g
> }
> do_something(lst)
>
>
>
Just reference the objects in the list:
do_something<-function(L){
lst$a+lst$b+lst$df+lst$g
}
do_something(lst)
On Sun, Nov 25, 2012 at 8:24 PM, Ally wrote:
> I'd like to pass a list object created by one function as an argument of
> another function. once inside the second function, I'd like
I'd like to pass a list object created by one function as an argument of
another function. once inside the second function, I'd like to break the
list up to it's individual elements, each then identifiable by the 'names'
of the list.
The list looks something like
lst<-list(a=1, b=2, df=5, g=7)
7 matches
Mail list logo