Ejemplo n.º 1
0
        private GenericVector ConvertToRList(VmResourceTrace trace)
        {
            var list = new GenericVector(R, 3);

            list.SetNames("vmId", "resourceId", "series");
            list["vmId"]       = new IntegerVector(R, new int[] { trace.VmId });
            list["resourceId"] = new IntegerVector(R, new int[] { (int)trace.Resource });
            list["series"]     = new NumericVector(R, trace.Series.Select(f => (double)(f)));
            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes the function. Match the function arguments by name.
        /// </summary>
        /// <param name="argNames">The names of the arguments. These can be empty strings for unnamed function arguments</param>
        /// <param name="args">The arguments passed to the function</param>
        /// <returns></returns>
        protected SymbolicExpression InvokeViaPairlist(string[] argNames, SymbolicExpression[] args)
        {
            var names = new CharacterVector(Engine, argNames);
            var arguments = new GenericVector(Engine, args);
            arguments.SetNames(names);
            var argPairList = arguments.ToPairlist();

            //IntPtr newEnvironment = Engine.GetFunction<Rf_allocSExp>()(SymbolicExpressionType.Environment);
            //IntPtr result = Engine.GetFunction<Rf_applyClosure>()(Body.DangerousGetHandle(), handle,
            //                                                      argPairList.DangerousGetHandle(),
            //                                                      Environment.DangerousGetHandle(), newEnvironment);
            return createCallAndEvaluate(argPairList.DangerousGetHandle());
        }
Ejemplo n.º 3
0
        private static SymbolicExpression DicoToSexp <T>(REngine engine, RDotNetConverter dataConverter, IEnumerable <KeyValuePair <string, T> > enumerable)
        // ReSharper restore UnusedMember.Local
        {
            var type   = typeof(T);
            var array  = enumerable.ToArray();
            var length = array.Length;

            var values = new SymbolicExpression[length];
            var names  = new string[length];

            for (var i = 0; i < length; i++)
            {
                names[i] = array[i].Key;
                var sexp = dataConverter.ConvertToSexp(type, array[i].Value);
                values[i] = sexp ?? engine.NilValue;
            }

            var vector = new GenericVector(engine, values);

            vector.SetNames(names);
            return(vector);
        }