Dear R-friends I have three matrices e.g. var <- matrix(c(4,4,4,4,0,4,4,4,0,3,3,0),nrow=4); val <- matrix(c(0.6,0.6,0.6,0.6,0,1.6,1.6,1.6,0,4.9,4.9,0),nrow=4); nod <- matrix(c(-1,-1,1,1),ncol=1) > var [,1] [,2] [,3] [1,] 4 0 0 [2,] 4 4 3 [3,] 4 4 3 [4,] 4 4 0 > val [,1] [,2] [,3] [1,] 0.6 0.0 0.0 [2,] 0.6 1.6 4.9 [3,] 0.6 1.6 4.9 [4,] 0.6 1.6 0.0 > nod [,1] [1,] -1 [2,] -1 [3,] 1 [4,] 1 Always there is same number of rows and columns for "var" and "val". Also no of rows of all three are always same. Combining them we get > cbind(var,val,nod) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] 4 0 0 0.6 0.0 0.0 -1 [2,] 4 4 3 0.6 1.6 4.9 -1 [3,] 4 4 3 0.6 1.6 4.9 1 [4,] 4 4 0 0.6 1.6 0.0 1
Is there any way to write them in the following form? [,1] [,2] [,3] [,4] [1,] 4(0.6) 0 0 -1 [2,] 4(0.6) 4(1.6) 3(4.9) -1 [3,] 4(0.6) 4(1.6) 3(4.9) 1 [4,] 4(0.6) 4(1.6) 0 1 Any help in this regard will be appreciated. best regards M.Azam [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.