[R] Putting all elementes of the list in an enviorment of a function
Aleš Žiberna
ales.ziberna at guest.arnes.si
Tue Aug 2 10:12:10 CEST 2005
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)
More information about the R-help
mailing list