build a sparse matrix with a defined size by usings 3 matrices - R
<p>I need to define a sparse matix with size with size <code>nrow(X)</code> which is made of these three matrices(II,JK,JH). thier size is equal to <code>3164*1</code>.
So far I got to the following command which is not correct. </p>

<pre><code>Gradient &lt;- sparseMatrix(II,JK,JH, dims=c(nrow(X),nrow(X)))
</code></pre>

<p>II has value from 3 to 82 (it has repeatation, for example 10 times value 3 and 14 times value 4).JK is also the same as II, but in II the values were sorted while in JK they do ot have and finally the JH which is -1 and 1.</p>

<p>Also the size of sparse matrix should be 83*83.</p>

<p>Any help would be grateful.</p>

<p>Thanks</p>