本文整理匯總了C#中RDotNet.REngine.CreateCharacterVector方法的典型用法代碼示例。如果您正苦於以下問題:C# REngine.CreateCharacterVector方法的具體用法?C# REngine.CreateCharacterVector怎麽用?C# REngine.CreateCharacterVector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RDotNet.REngine
的用法示例。
在下文中一共展示了REngine.CreateCharacterVector方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestPendingFinalizersThreadingIssues
private static void TestPendingFinalizersThreadingIssues(REngine e)
{
e.Evaluate("f <- function(a) {if (length(a)!= 1) stop('What goes on?')}");
var f = e.Evaluate("f").AsFunction();
try
{
e.Evaluate("f(letters[1:3])");
}
catch (EvaluationException)
{
}
f.Invoke(e.CreateCharacterVector(new[] { "blah" }));
try
{
f.Invoke(e.CreateCharacterVector(new[] { "blah", "blah" }));
}
catch (EvaluationException)
{
Console.WriteLine("Caught the expected exception");
}
f = null;
GC.Collect();
GC.WaitForPendingFinalizers();
e.Dispose();
Console.WriteLine("Just waiting for crash...");
GC.Collect();
GC.WaitForPendingFinalizers();
}
示例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: ReproInMemoryDataFrameCreation
private static void ReproInMemoryDataFrameCreation(REngine e)
{
e.Evaluate("f <- function(a) {if (length(a)!= 1) stop('What goes on?')}");
var f = e.Evaluate("f").AsFunction();
try
{
e.Evaluate("f(letters[1:3])");
}
catch (EvaluationException)
{
}
f.Invoke(e.CreateCharacterVector(new[] { "blah" }));
f.Invoke(e.CreateCharacterVector(new[] { "blah", "blah" }));
// IEnumerable[] columns, string[] columnNames = null, string[] rowNames = null, bool checkRows = false, bool checkNames = true, bool stringsAsFactors = true);
var columns = new[] {
new[]{1,2,3,4,5},
new[]{1,2,3,4,5},
new[]{1,2,3,4,5}
};
var df = e.CreateDataFrame(columns, new[] { "a", "b", "c" });
columns[1] = new[] { 1, 2, 3 };
object blah;
try
{
df = e.CreateDataFrame(columns, new[] { "a", "b", "c" });
blah = df[1, 1];
}
catch
{
}
df = e.CreateDataFrame(columns, new[] { "a", "b", "c" });
blah = df[1, 1];
}
示例4: CreateCharacterVector
public static void CreateCharacterVector(REngine engine, int n, Stopwatch s)
{
string[] d = createStringArray(n);
s.Start();
var nvec = engine.CreateCharacterVector(d);
s.Stop();
}
示例5: ToVector
internal static SymbolicExpression ToVector(REngine engine, IEnumerable values)
{
if (values == null) throw new ArgumentNullException("values", "values to transform to an R vector must not be null");
var ints = values as IEnumerable<int>;
var chars = values as IEnumerable<string>;
var cplxs = values as IEnumerable<Complex>;
var logicals = values as IEnumerable<bool>;
var nums = values as IEnumerable<double>;
var raws = values as IEnumerable<byte>;
var sexpVec = values as SymbolicExpression;
if (sexpVec != null && sexpVec.IsVector())
return sexpVec;
if (ints != null)
return engine.CreateIntegerVector(ints);
if (chars != null)
return engine.CreateCharacterVector(chars);
if (cplxs != null)
return engine.CreateComplexVector(cplxs);
if (logicals != null)
return engine.CreateLogicalVector(logicals);
if (nums != null)
return engine.CreateNumericVector(nums);
if (raws != null)
return engine.CreateRawVector(raws);
throw new NotSupportedException(string.Format("Cannot convert type {0} to an R vector", values.GetType()));
}