Message-ID: <4EE21A31.6060703@email.uni-kiel.de>
Date: 2011-12-09T14:24:49Z
From: Christof Kluß
Subject: apply on function with vector as result
In-Reply-To: <CAM_vjukhFfE-m+Nm+xnRAfT9vsjp2XDORneVmSm2rDuVXOvQEw@mail.gmail.com>
Am 09-12-2011 12:54, schrieb Sarah Goslee:
>> myfunc<- function(x) {a=x; b=x-1; c(a, b) }
>> ys<- sapply(1:5, myfunc)
>> ys
> [,1] [,2] [,3] [,4] [,5]
> [1,] 1 2 3 4 5
> [2,] 0 1 2 3 4
>
> And from there, it's not at all clear what you mean by "one vector" -
> in what order? All of the a then all of the b values? abab?
>
> as.vector(ys) and as.vector(t(ys)) will accomplish those.
>
> Or do you mean simply
> as<- ys[1,]
> bs<- ys[2,]
Thank you very much! That is what I was looking for. Sorry that I have
expressed myself so unclear.
Greetings
Christof