Incorrect work of track package in R.NET

僤鯓⒐⒋嵵緔 提交于 2019-12-02 06:16:02

问题


I have same problem when trying to use R.NET with track package (it needs for tracking variables, which were modified via R code ran).

So, it native R code, which works fine:

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

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

track.stop();

I have output like this:

> 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>

So, while I try to realize complementary code via R.NET (see code below)

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();
        }
    }
}

I have another output, where track.summary() doesn't consist of anything:

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>

What's the reason, does anybody know? Thank you.

来源:https://stackoverflow.com/questions/33798029/incorrect-work-of-track-package-in-r-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!