What types can be passed from R to C#

Jul 1, 2015 at 3:09 PM
Is there any documentation on the type conversion that can be handled in going from R to C#?

for example I have tried this:
  mylist2 <- list("a","b","c")
  clrCallStatic(myType, "TestTypesB",  mylist2)
against this:
    public static int TestTypesB(List<string> ddd)
        return 2;
Which throws an exception

Calling it against this
    public static int TestTypesA(object ddd)
        return 1;
does not crash and the object ddd has three entries but they are all null.
Jul 4, 2015 at 2:26 AM
There is a table in the vignette included in the package showing some type conversions. Most if not all are bidirectional.

More documentation is warranted for things like lists, but some behaviors remain to be defined, and it is hard to find a balance between predictability and "smart" type coercions.

For something like your example, I would definitely stick to passing character vectors c('a','b','c') to a function that accepts string[] mArray as parameter. Yes it may not match the C# API you already have, and you may need to code a thin C# wrapper, but the expected behavior is then unambiguous.

R lists can contain just about anything, and there is a clash between the dynamic and static type systems of R and .NET respectively. It is sensible to transform a collection of objects from .NET into a list of objects in R. Going the other way is much more ambiguous, and a real can of worm.