Adding a matrix to a list in R
<p>I have a list corresponding to the matrix of a .png image without the RGB transparency information. The dimension of the matrix is <code>128 128 3</code>. So I have a <code>128 x 128</code> matrix coding the red hues in each pixel; a <code>128 x 128</code> matrix coding the greens; and a <code>128 x 128</code> matrix for the blues. There is no transparency in the image, but to write this .png, I think I need to include a <code>128x128</code> matrix of <code>1</code>'s and tag it to my list so as to get a <code>128 x 128 x 4</code> matrix.</p>

<p>How can I append this matrix of ones to my list?</p>

<p>I have a list named <code>compressed</code> with these dimensions (<code>128 128 3</code>), and I've tried multiple single and double-bracketed ways to include something like <code>matrix(rep(1, 128^2), nrow= 128)</code> without success.</p>

<p>The idea is to eventually save it as:</p>

<pre><code>require(png)
writePNG(compressed, "compressed.picture")
</code></pre>

<p>without doing away with color.</p>