I'd like to use an API from R that is only available in .NET. Is there a standard method that can be used to call .NET C# code from R? If so, how can I do so?
. NET Framework is an object oriented programming framework meant to be used with languages that it provides bindings for. Since C is not an object oriented language it wouldn't make sense to use it with the framework.
The main conclusion is that one is not better than the other, and we shouldn't compare them since RestSharp is a wrapper around HttpClient.
C++/CLI can call any C# function as if it were a "regular" C++ function. Add your references, /clr and It Just Works.
Another option that readers of this discussion might consider is the rClr package, which I have been working on for a couple of years to access arbitrary .NET code from R. It is a sibling of R.NET which, conversely, is a way to access R from .NET.
To give a flavour of the rClr package, the canonical "Hello World" looks like:
library(rClr)
clrLoadAssembly('c:/path/to/myassembly.dll')
myObj <- clrNew('MyNamespace.MyClass,MyAssemblyName')
clrCall(myObj, 'SayHelloWorld')
Feedback and suggestions welcome via the web site.
Exposing the .NET dll as COM dll and then calling a COM object in the dll from R seem to be the only way. And there is a package for it: http://cran.r-project.org/web/packages/rcom/rcom.pdf
If you cannot make a COM dll because it's third-party dll, you can always create a new interface-like .NET dll with COM interface where you can call actual dll.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With