This project is read-only.

Getting regression coefficients from R.Net

Apr 1, 2014 at 6:45 PM
Edited Apr 1, 2014 at 6:48 PM
Hello

New to R.Net, somewhat less new to C# ( I mostly use VB)

Not sure how to get regression coefficients from this example. The watch window in visual studio doesn't provide much help when I look at testResult.

Thanks any help greatly appreciated.
NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 35.99, 30.11, 29.97, 30.01, 29.99 });
NumericVector group2 = engine.Evaluate("group2 <- c(29.89, 29.93, 37.72, 29.98, 30.02, 29.98)").AsNumeric();
GenericVector testResult = engine.Evaluate("lm(group1 ~ group2)").AsList();
Apr 1, 2014 at 7:03 PM
engine.Evaluate("coefficients(lm(group1 ~ group2))").AsNumeric();
Apr 1, 2014 at 7:08 PM
Thanks!

I guess I would precede it by

NumericVector coeff = engine.Evaluate("coefficients(lm(group1 ~ group2))").AsNumeric();

and then look at the elements one by one. This is a tremendous help.