Concatenating Matrices with for loop command in R -


consider reproducible data in generate 5 random matrices. want combine data in first row of each matrix

set.seed(123)  result <- foreach(i=1:5) %do%{   # randomly select number of rows , columns     random.rows <- sample(1:5, 1)   random.columns <- sample(1:5, 1)   # generate matrix out of   matrix(sample(1:100, random.rows*random.columns), random.rows) } 

the desired output should take form:

c(result[[1]][1,], result[[2]][1,], result[[3]][1,] # ........   ) 

i trying implement for-loop in real life, have more 5 matrices. can guide me towards desired output

for (i in 1:5) {   desired_out <- c(result[[i]][1,]) } 


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -