Merge Two Arrays in R -


suppose have 2 arrays, array1 , array2, like

array1

        45    46   47    48    49    50         1.0   1.5  1.3   1.2   0.9   1.1 

array2

        45    46   47    48    49    50         2.5   5.5  4.5   5.8   1.5   8.4 

and want merge them data frame looks like:

       1.0  2.5        1.5  5.5        1.3  4.5        1.2  5.8        0.9  1.5        1.1  8.4 

the numbers 45 50 don't matter.

 array1 <- c(1.0,1.5,1.3,1.2,0.9,1.1)  array2 <- c(2.5,5.5,4.5,5.8,1.5,8.4)   result = cbind(array1, array2) 

in case don't want see column names or row names (as posted in question), should following:

 result = as.matrix(cbind(array1, array2))   dimnames(result) <-list(rep("", dim(result)[1]), rep("", dim(result)[2])) 

you get:

 > result    1.0 2.5   1.5 5.5   1.3 4.5   1.2 5.8   0.9 1.5   1.1 8.4 

Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -