Skip to content
Back to formatted view

Raw Message

Message-ID: <jbss2o$5ec$1@dough.gmane.org>
Date: 2011-12-09T11:40:03Z
From: Christof Kluß
Subject: apply on function with vector as result

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