Matrix Math With Sparklyr : <p>Looking to convert some R code to Sparklyr, functions such as lmtest::coeftest() and sandwich::sandwich(). Trying to get started with Sparklyr extensions but pretty new to the Spark API and having issues :(</p>

<p>Running Spark 2.1.1 and sparklyr 0.5.5-9002</p>

<p>Feel the first step would be to make a <a href="https://spark.apache.org/docs/2.1.1/api/scala/index.html#org.apache.spark.mllib.linalg.DenseMatrix" rel="noreferrer">DenseMatrix</a> object using the linalg library:</p>

<pre><code>library(sparklyr)
library(dplyr)
sc &lt;- spark_connect("local")

rows &lt;- as.integer(2)
cols &lt;- as.integer(2)
array &lt;- c(1,2,3,4)

mat &lt;- invoke_new(sc, "org.apache.spark.mllib.linalg.DenseMatrix", 
                  rows, cols, array)
</code></pre>

<p>This results in the error:</p>

<pre><code>Error: java.lang.Exception: No matched constructor found for class org.apache.spark.mllib.linalg.DenseMatrix
</code></pre>

<p>Okay, so I got a java lang exception, I'm pretty sure the <code>rows</code> and <code>cols</code> args were fine in the constructor, but not sure sure about the last one, which is supposed to be a java <code>Array</code>. So I tried a few permutations of:</p>

<pre><code>array &lt;- invoke_new(sc, "java.util.Arrays", c(1,2,3,4))
</code></pre>

<p>but end up with a similar error message...</p>

<pre><code>Error: java.lang.Exception: No matched constructor found for class java.util.Arrays
</code></pre>

<p>I feel like I'm missing something pretty basic. Anyone know what's up?</p>
