Пример #1
0
 def __enter__(self):
     from System import Environment
     if self._prepend:
         Environment.SetEnvironmentVariable(
             self._variable,
             "%s%s%s" % (self._value, self._sep, self._oldval))
     else:
         Environment.SetEnvironmentVariable(self._variable, self._value)
Пример #2
0
 def __exit__(self, *args):
     from System import Environment
     Environment.SetEnvironmentVariable(self._variable, self._oldval)
Пример #3
0
import clr
clr.AddReferenceToFileAndPath(r'C:\src\R\rdotnet\R.NET\bin\Debug\RDotNet.dll')
clr.AddReferenceToFileAndPath(r'C:\src\trunk\Partners\CSIRO\R\CSIRO.TIME2R\bin\Debug\CSIRO.TIME2R.dll')
clr.AddReference("System.Core")
from CSIRO.TIME2R import *
import System
import RDotNet
from RDotNet import *
clr.ImportExtensions(System.Linq)
clr.ImportExtensions(RDotNet) 
clr.ImportExtensions(SymbolicExpressionExtension) 
rdllloc = r"c:\bin\R\R\bin\x64"
REngine.SetDllDirectory(rdllloc)
from System import Environment
rhome = Environment.GetEnvironmentVariable("R_HOME")
Environment.SetEnvironmentVariable("R_HOME", r"c:\bin\R\R")
engine = REngine.CreateInstance("RDotNet", r"c:\bin\R\R\bin\x64\R.dll")
engine.Initialize()
sexp = "data.frame(name=paste('x', 1:4, sep=''), min = rep(0,4), value= rep(1,4), max = rep(2,4), stringsAsFactors=FALSE)"
df = SymbolicExpressionExtension.AsDataFrame(engine.Evaluate(sexp))
hc = TimeToRDataConversion.convert(df)



// .NET Framework array to R vector.
NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 });
engine.SetSymbol("group1", group1);
// Direct parsing from R script.
NumericVector group2 = engine.Evaluate("group2 <- c(29.89, 29.93, 29.72, 29.98, 30.02, 29.98)").AsNumeric();
group2[2] = 3.1415;
engine.Evaluate("print(group2)");