[R] apply on function with vector as result
Christof Kluß
ckluss at email.uni-kiel.de
Fri Dec 9 12:40:03 CET 2011
Hi,
a have some code like
myfunc <- function(x) { ...; return c(a,b) }
ys <- sapply(0:100,myfunc)
so I get something like c(c(a1,b1),c(a2,b2),...)
But now I need the "as" and "bs" in one vector
as <- apply(ys, function(c(a,b)) a)
bs <- apply(ys, function(c(a,b)) b)
Can you help me with the correct syntax, instead of my pseudo code?
thx
Christof
More information about the R-help
mailing list