layout: site title: R to DML

To ease the prototyping of the dml scripts from its R counterparts, this guide covers various practical functions or operations.

NOTE: This document is still a work in progress.

Table of Contents

Multiple-outputs

# dml

A = rand(rows=10, cols=10)
C = t(A) %*% A
[evalues, evectors] = eigen(C);
# R

A = rand(rows=10, cols=10)
C = t(A) %*% A
R <- eigen(C);
evalues = R$values;
evectors = R$vectors;

order-function

# dml

decreasing_Idx = order(target=evalues,by=1,decreasing=TRUE,index.return=TRUE);
diagmat = table(seq(1,D),decreasing_Idx);
# R

decreasing_Idx = order(as.vector(evalues), decreasing=TRUE);
diagmat = table(seq(1,D), decreasing_Idx);

Read-function

# dml

A = read("")
# A = read($INPUT)
# R

# args[1] will the relative directory path
A = readMM(paste(args[1], "A.mtx", sep=""))

Write-function

# dml
ofmt = "TEXT"

write(evalues, "evalues", format=ofmt)
# R

# Here args[2] will be a string denoting output directory
writeMM(as(evalues, "CsparseMatrix"), paste(args[2],"evalues", sep=""));