[R] Concatenate two strings in one in a string matrix

Eduardo Mendes
Thu, 18 Aug 2011 18:35:50 -0000

Dear R-Users

I have the following matrix

> out$desc      [,1]            [,2]
 [1,] ""              ""
 [2,] "y_{01}(k-001)" ""
 [3,] "y_{01}(k-002)" ""
 [4,] "y_{01}(k-003)" ""
 [5,] "u_{01}(k-001)" ""
 [6,] "u_{01}(k-002)" ""
 [7,] "u_{01}(k-003)" ""
 [8,] "y_{01}(k-001)" "y_{01}(k-001)"
 [9,] "y_{01}(k-001)" "y_{01}(k-002)"
[10,] "y_{01}(k-001)" "y_{01}(k-003)"
[11,] "y_{01}(k-001)" "u_{01}(k-001)"


and need to concatenate each line to a single string.  Something like

[2,] "y_{01}(k-001)" ""  -> [2,]
"y_{01}(k-001)"

[11,] "y_{01}(k-001)" "u_{01}(k-001)" -> [11,]
"y_{01}(k-001)*u_{01}(k-001)"


Is there a way to do it without going through every column?

Many thanks

Ed

	[[alternative HTML version deleted]]