I'm using VS2013 and R.net to execute some R script which is suppose to return matrix but it doesn't work.
here is the script :
m0 <- matrix(NA, 4, 0)
m2 <- cbind(1, 1:4)
colnames(m2) <- c('x','Y')
rownames(m2) <- rownames(m2, do.NULL = FALSE, prefix = 'Obs.')
m2
I would get this result if I ran it in R environment which is correct:
x Y
Obs.1 1 1
Obs.2 1 2
Obs.3 1 3
Obs.4 1 4
also if I execute it through R.net like below it works just fine and will return a NumericMatrix:
SymbolicExpression output = null;
engine.Evaluate("m0 <- matrix(NA, 4, 0)");
engine.Evaluate("m2 <- cbind(1, 1:4)");
engine.Evaluate("colnames(m2) <- c('x','Y')");
engine.Evaluate("rownames(m2) <- rownames(m2, do.NULL = FALSE, prefix = 'Obs.')");
output = engine.Evaluate("m2");
var matrix = output.AsNumericMatrix();
and matrix variable has contain a matrix ( 4 rows and 2 columns)
here is the script :
m0 <- matrix(NA, 4, 0)
m2 <- cbind(1, 1:4)
colnames(m2) <- c('x','Y')
rownames(m2) <- rownames(m2, do.NULL = FALSE, prefix = 'Obs.')
m2
I would get this result if I ran it in R environment which is correct:
x Y
Obs.1 1 1
Obs.2 1 2
Obs.3 1 3
Obs.4 1 4
also if I execute it through R.net like below it works just fine and will return a NumericMatrix:
SymbolicExpression output = null;
engine.Evaluate("m0 <- matrix(NA, 4, 0)");
engine.Evaluate("m2 <- cbind(1, 1:4)");
engine.Evaluate("colnames(m2) <- c('x','Y')");
engine.Evaluate("rownames(m2) <- rownames(m2, do.NULL = FALSE, prefix = 'Obs.')");
output = engine.Evaluate("m2");
var matrix = output.AsNumericMatrix();
and matrix variable has contain a matrix ( 4 rows and 2 columns)