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

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -