How about:
Use mapply
but don't simplify.
result1 <- mapply(func, x=df, SIMPLIFY=FALSE)
Iterate over the indices (this assumes both lists in the result are the same length); for each index i
, use lapply
to pull out the i
th element of each list in result1
.
result2 <- lapply(seq_along(result1[[1]]),
function(i) lapply(result1,"[[",i))
I tried a little bit to shorten/obfuscate this still further (i.e. remove the need to define an anonymous function), but with nested lapply
s I can't quite figure out how to make it work.