Re: [R] Passing lists between functions

2012-11-25 Thread Ally
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

Re: [R] Passing lists between functions

2012-11-25 Thread Rolf Turner
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

Re: [R] Passing lists between functions

2012-11-25 Thread Ally
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

Re: [R] Passing lists between functions

2012-11-25 Thread arun
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

Re: [R] Passing lists between functions

2012-11-25 Thread jim holtman
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) > > >

Re: [R] Passing lists between functions

2012-11-25 Thread jim holtman
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

[R] Passing lists between functions

2012-11-25 Thread Ally
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)