How to even start?

Sep 20, 2013 at 1:01 PM
Hi,

So I tried following the start up documentation verbatim but it only crashes. Is there a better (working) guide out there?

Cheers,
Ben
Developer
Sep 21, 2013 at 12:56 PM
Hi,

As for most software, the documentation is an ongoing effort.
It would be useful to know what crashes where, and with what O/S and software versions. It would help clarify and improve the documentation.

Cheers
Sep 22, 2013 at 4:15 AM
Hi,

So the first problem is that an engine doesn't exist in the current context; The documentation doesn't tell you how to create an engine. Following code here kind of works (but if you follow it exactly is comes up with errors about it being redundant code re. setting the directory - I tried just using the code to create an instance of an engine.).

The second is that e can't be set as a variable (easy to change but the example code shouldn't use "e")

Thirdly, the demo commands don't work

for example: (e is changed to x)

var x = engine.Defer("x<-3"); makes this error
Error 1 The best overloaded method match for 'RDotNet.REngine.Defer(System.IO.Stream)' has some invalid arguments S:\SkyDrive\Documents\Projects\R.net test\R.net_TESTER\R.net_TESTER\Form1.cs 46 24 R.net_TESTER
If I change it to engine.evaluate it makes an invalid operator exception at runtime.

x.ToArray(); makes this error
Error 1 'RDotNet.SymbolicExpression' does not contain a definition for 'ToArray' and no extension method 'ToArray' accepting a first argument of type 'RDotNet.SymbolicExpression' could be found (are you missing a using directive or an assembly reference?) S:\SkyDrive\Documents\Projects\R.net test\R.net_TESTER\R.net_TESTER\Form1.cs 51 13 R.net_TESTER


So yea - like I said the documentation is not at all helpful beyond setting the .dll directory (either that or R.net is that buggy). Which sucks because I'd really like to use R.net (RDotCom seems useless for anything needing redistribution) but as it stands it's unusable...

I'm using Win7 and R.net 1.5.5
Sep 22, 2013 at 4:27 AM
Also when I just start the form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using R;
using RDotNet;
using RDotNet.NativeLibrary;


namespace R.net_TESTER
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        //!++ FORM LOAD
        private void Form1_Load(object sender, EventArgs e)
        {
            //++ Set R directory on load
            var oldPath = System.Environment.GetEnvironmentVariable("PATH");
            //Run 64 bit if possible!
            var rPath = System.Environment.Is64BitProcess ? @"C:\Program Files\R\R-3.0.1\bin\x64" : @"C:\Program Files\R\R-3.0.1\bin\i386";
            var newPath = System.String.Format("{0}{1}{2}", rPath, System.IO.Path.PathSeparator, oldPath);
            System.Environment.SetEnvironmentVariable("PATH", newPath);

           

        }
I get a bunch of exceptions in the immediate window:

A first chance exception of type 'System.ArgumentException' occurred in RDotNet.dll
A first chance exception of type 'System.InvalidOperationException' occurred in RDotNet.dll
A first chance exception of type 'System.InvalidOperationException' occurred in RDotNet.dll
A first chance exception of type 'System.ArgumentException' occurred in RDotNet.dll
A first chance exception of type 'System.ArgumentException' occurred in RDotNet.dll
A first chance exception of type 'System.ArgumentException' occurred in RDotNet.dll
Developer
Sep 22, 2013 at 10:14 AM
Thanks for the precisions.

I created a code repository to check the current documentation against R.NET 1.5.5. I intend this to be a basis for more fleshed out tutorials, gradually capitalising on the R.NET discussion list. the repository is rdotnet-onboarding on GitHub. This is just convenient for me right now; I am not making a point to have a repo outside of codeplex...

A few remarks:
  • The current documentation page has at least an incorrect usage of the Defer method indeed as of R.NET 1.5.5. Never had the use for it, so I'd suggest you ignore it for the time being.
  • Swapping for .Evaluate("x <- 3") indeed throws an exception. That was a bad surprise. Well spotted. Thanks. Logged in https://rdotnet.codeplex.com/workitem/55
  • If you are in a discovery phase of a new library such as R.NET, I'd recommend you avoid using forms, which can foster unnecessary complication in the learning process, and use console applications. Your choice.
  • I assume you cannot use 'e' as a variable name simply because it is already used for an EventArgs type in the forms method. See my previous advice.