Missing tab characters in RDotNet stdout output

Mar 13, 2015 at 12:25 AM
Edited Mar 13, 2015 at 1:27 AM
In RGui on Windows 7, if I create the following vector and print it...
> ar = c(1, 12, 123, 1234, 12345, 123456, 1234567, 12345678)
> print(ar)
[1]        1       12      123     1234    12345   123456  1234567 12345678
Now the same thing but with RDotNet 1.5.21 on Windows 7...

If I call _engine.Evaluate("ar = c(1, 12, 123, 1234, 12345, 123456, 1234567, 12345678)"); and then separately, _engine.Evaluate("print(ar)");, I get the following disturbing output on stdout (the console):
[1]112123123412345123456123456712345678
Now, I do want the output, I just want it to contain the tab characters it's supposed to have to separate the elements of the vector. Without the tabs, the output is useless. (BTW, this is a trivial example of what I actually need to do; please don't tell me to use numeric data types & handle my results programmatically, as that defeats the purpose of what I'm doing.)

Any ideas? Thanks in advance.
Mar 13, 2015 at 2:11 PM
Edited Mar 13, 2015 at 2:12 PM
The ConsoleDevice seems to be trimming the whitespace. I'm not certain why.


https://github.com/jmp75/rdotnet/blob/master/R.NET/Devices/ConsoleDevice.cs#L33
public void WriteConsole(string output, int length, ConsoleOutputType outputType)
{
    output = output.Trim(' ');
    Console.Write(output);
}
Mar 13, 2015 at 6:15 PM
Wow, thank you very very much. Commenting out that single line (output = output.Trim(' ');) fixes the problem, and now RDotNet's stdout output looks exactly like what RGui shows. Now even the output of commands like ls.str() looks right... thank you again very very much.

So I guess I need to submit a pull request? I'm not interested in actually adding RDotNet as a project in my product's solution; I'd much rather continue using NuGet to get the latest release. Any idea on how fast this change can get into the NuGet latest release?
Mar 13, 2015 at 6:21 PM
Hmm. Looking at the Hg history, somebody named 'skyguy94' added that line on 2014-11-12 in the 'FontImprovements' branch. I wonder how that improves font handling? :)
Mar 14, 2015 at 2:44 AM
Dammit...caught in the act! I have no idea. I blame the PR reviewers....
Mar 14, 2015 at 11:22 PM
I really don't know where that line came from. I looked at the history for my private version and I got rid of it at some point. Here's the current implementation of my console device:
      public void WriteConsole(string output, int length)
      {
          WriteConsoleEx(output, length, ConsoleOutputType.Output);
      }

      public void WriteConsoleEx(string output, int length, ConsoleOutputType outputType)
      {
         Console.Write(output);
      }
Developer
Mar 16, 2015 at 6:45 AM
I will remove this line from the master branch.

The implementation with WriteConsoleEx is on the client_server branch. I have yet to find the time to revisit and incorporate your (@skyguy94) client/server into the master. We are probably looking at a new nuget package structure for that, for one thing.
Mar 16, 2015 at 1:48 PM
That branch is a good prototype, and meets our needs internally. I have a better rewrite of that coming that is cross-platform like people are looking for, plus a few other tweaks, like different service serialization options Jil for JSON and ProtocolBuffers. It'll probably "be coming" for a while though.