r - How to name foreach matrix columns? -
just question neat way name result matrix of foreach loop. works, it's bit verbose, wonder if there simpler method:
r = foreach( i=seq(5), .combine=rbind, .final=function(res) { colnames(res) = c("first", "second"); return(res) } ) %dopar% { c(i, i+1) }
put column names in rhs of %dopar%
:
foreach(i=seq(5), .combine=rbind) %dopar% { c(first=i, second=i+1) }
Comments
Post a Comment