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 :(
Running Spark 2.1.1 and sparklyr 0.5.5-9002
Feel the first step would be to make a DenseMatrix object using the linalg library:
library(sparklyr)
library(dplyr)
sc <- spark_connect("local")
rows <- as.integer(2)
cols <- as.integer(2)
array <- c(1,2,3,4)
mat <- invoke_new(sc, "org.apache.spark.mllib.linalg.DenseMatrix",
rows, cols, array)
This results in the error:
Error: java.lang.Exception: No matched constructor found for class org.apache.spark.mllib.linalg.DenseMatrix
Okay, so I got a java lang exception, I'm pretty sure the rows
and cols
args were fine in the constructor, but not sure sure about the last one, which is supposed to be a java Array
. So I tried a few permutations of:
array <- invoke_new(sc, "java.util.Arrays", c(1,2,3,4))
but end up with a similar error message...
Error: java.lang.Exception: No matched constructor found for class java.util.Arrays
I feel like I'm missing something pretty basic. Anyone know what's up?