R.NET中跟踪包的工作不正确

时间:2015-11-19 07:51:57

标签: r r.net

我在尝试将R.NET与track包一起使用时遇到同样的问题(它需要跟踪变量,这些变量是通过R代码运行修改的)。

所以,它本机R代码,工作正常:

library(track);
track.start(clobber = "vars", dir = file.path(tempdir(), 'rdata123'));

a <- 5;
print(track.summary());
print(ls(globalenv()));

track.stop();

我有这样的输出:

> library(track);
> track.start(clobber = "vars", dir = file.path(tempdir(), 'rdata123'));
Tracking <env R_GlobalEnv> (writable) using existing directory     'C:\Users\Rebelion\AppData\Local\Temp\RtmpGmyc4B/rdata123'
> 
> a <- 5;
> print(track.summary());
class    mode extent length size            modified TA TW
a numeric numeric    [1]      1   48 2015-11-19 10:44:34  0  2
> print(ls(globalenv()));
[1] "a"
> 
> track.stop();
Stopping tracking on <env R_GlobalEnv>

因此,当我尝试通过R.NET实现补充代码时(参见下面的代码)

using System;
using RDotNet;

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            REngine.SetEnvironmentVariables();
            var engine = REngine.GetInstance();

            engine.Initialize();

            engine.Evaluate("library(track);");
            engine.Evaluate(@"track.start(auto = TRUE, clobber = ""vars"", dir = file.path(tempdir(), 'rdatadir123456'))");

            engine.Evaluate("a <- 5;");
            engine.Evaluate("print(track.summary());");
            engine.Evaluate("print(ls(globalenv()));");

            engine.Evaluate("track.stop();");

            Console.ReadLine();
        }
    }
}

我有另一个输出,其中track.summary()不包含任何内容:

Tracking <env R_GlobalEnv> (writable) using new directory 'C:\Users\Rebelion\AppData\Local\Temp\RtmpiQEGgY/rdatadir123456'
[1] class    mode     extent   length   size     modified TA       TW
<0 строк> (или 'row.names' нулевой длины)
[1] "a"
Stopping tracking on <env R_GlobalEnv>

是什么原因,有人知道吗? 谢谢。

0 个答案:

没有答案