本文整理匯總了C#中RDotNet.REngine.SetSymbol方法的典型用法代碼示例。如果您正苦於以下問題:C# REngine.SetSymbol方法的具體用法?C# REngine.SetSymbol怎麽用?C# REngine.SetSymbol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RDotNet.REngine
的用法示例。
在下文中一共展示了REngine.SetSymbol方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: calcSDev
static double calcSDev (REngine engine, double[] arr)
{
// Note: only one quick and slightly dirty way to do it
NumericVector rVector = engine.CreateNumericVector(arr);
engine.SetSymbol ("x", rVector);
return engine.Evaluate ("sd(x)").AsNumeric () [0];
}
示例2: GenetateLatencyVsMessageLengthPlot_RScript
static void GenetateLatencyVsMessageLengthPlot_RScript(REngine engine, string latencyCsvFilename)
{
//For formatting purposes, make sure the filename is acceptable for R function read.csv
string fileToReadFromCommand = latencyCsvFilename.Replace(@"\", @"/");
//Convert to R character vector
CharacterVector cvFilename = engine.CreateCharacterVector(new[] { fileToReadFromCommand });
// and assign it to variable (in R engine) called fileToReadFrom
engine.SetSymbol("fileToReadFrom", cvFilename);
//And then evaluate the script - this uses the 'fileToReadFrom' in a read.csv call
engine.Evaluate(MyRDotNetApplication.Properties.Resources.latencyVsMessageLengthScatterPlot); //R-Script to generate plot
}
示例3: UserReported
private static DataFrame UserReported(REngine engine)
{
// Incomplete data and repro info.
// See https://rdotnet.codeplex.com/discussions/569196
NumericVector PreprocessedValue = null;
DataFrame PredictedData = null;
// Some info was missing. Make up.
string StartDate = "2001-01-01";
double[] PreProcessedList = new[] { 1.1, 7.3, 4.5, 7.4, 11.23, 985.44 };
string days = "2"; string interval = "3";
PreprocessedValue = engine.CreateNumericVector(PreProcessedList);
// Assign the Utilization value to R variable UtilValue
engine.SetSymbol("PreprocessedValue", PreprocessedValue);
engine.Evaluate("library(forecast)");
engine.Evaluate("StartDate <- as.Date('" + StartDate + "') + " + days);
engine.Evaluate("size = length(seq(from=as.Date('" + StartDate + "'), by='" + "day" + "', to=as.Date(StartDate)))");
engine.Evaluate("startDate <- as.POSIXct('" + StartDate + "')");
engine.Evaluate("endDate <- StartDate + as.difftime(size, units='" + "days" + "')");
engine.Evaluate("PredictDate = seq(from=StartDate, by=" + interval + "*60, to=endDate)");
engine.Evaluate("freq <- ts(PreprocessedValue, frequency = 20)");
engine.Evaluate("forecastnavie <-snaive(freq, Datapoints)");
engine.Evaluate("PredictValue = (forecastnavie$mean)");
engine.Evaluate("PredictedData = cbind(PredictValue, data.frame(PredictDate))");
PredictedData = engine.Evaluate("PredictedData").AsDataFrame();
return PredictedData;
}
示例4: ReproWorkitem43
private static void ReproWorkitem43(REngine engine)
{
Random r = new Random(0);
int N = 500;
int n1 = 207;
int n2 = 623;
var arGroup1Intensities = new double[N][];
var arGroup2Intensities = new double[N][];
for (int i = 0; i < N; i++)
{
arGroup1Intensities[i] = new double[n1];
arGroup2Intensities[i] = new double[n2];
for (int j = 0; j < n1; j++)
arGroup1Intensities[i][j] = r.NextDouble();
for (int j = 0; j < n2; j++)
arGroup2Intensities[i][j] = r.NextDouble();
}
var res = new GenericVector[N];
NumericVector vGroup1, vGroup2;
for (int i = 0; i < N; i++)
{
vGroup1 = engine.CreateNumericVector(arGroup1Intensities[i]);
Console.WriteLine(vGroup1.Length);
if (i % 10 == 4)
{
engine.ForceGarbageCollection();
engine.ForceGarbageCollection();
}
vGroup2 = engine.CreateNumericVector(arGroup2Intensities[i]);
Console.WriteLine(vGroup2.Length);
engine.SetSymbol("group1", vGroup1);
engine.SetSymbol("group2", vGroup2);
GenericVector testResult = engine.Evaluate("t.test(group1, group2)").AsList();
res[i] = testResult;
}
}
示例5: setValueAndMeasure
private static void setValueAndMeasure(REngine engine, Stopwatch s, Func<REngine, Array> fun, string symbolName, string vStatement)
{
engine.SetSymbol(symbolName, engine.Evaluate(vStatement));
//engine.Evaluate("cat(ls())");
measure(engine, s, fun);
}