11
In R we can make a function return more than one object through a list. But how to assign these objects to two distinct variables?
Example:
f<-function(){
primeiro<-1:10
segundo<-11:21
return (list(primeiro,segundo))
}
With the above function I can assign and access the objects as follows.
d<-f()
d[1]
d[2]
But I cannot assign these values to different variables through a list
list(a,b)<-f()
I want to assign to each variable - "a" and "b" - one of the result objects of function f(). The Python equivalent would be:
def f():
primeiro=range(1,11)
segundo=range(11,20)
return (primeiro,segundo)
(a,b)=f()
print a
print b