Skip to content

Instantly share code, notes, and snippets.

@chamathabeysinghe
Created February 17, 2018 18:23
Show Gist options
  • Save chamathabeysinghe/8f338700cea6feac5a1c724770aa99a5 to your computer and use it in GitHub Desktop.
Save chamathabeysinghe/8f338700cea6feac5a1c724770aa99a5 to your computer and use it in GitHub Desktop.
ml = MLContext(spark)
matrixScript = dml(
"""
fileM = 'test_csv.csv'
numRowsToPrint = ifdef($rowsToPrint, 2) # default to 2
numColsToPrint = ifdef($colsToPrint, 2) # default to 2
m = read(fileM)
for (i in 1:numRowsToPrint) {
for (j in 1:numColsToPrint) {
print('[' + i + ',' + j + ']:' + as.scalar(m[i,j]))
}
}
"""
)
ml.execute(matrixScript)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment