Coder Social home page Coder Social logo

rdotnet / rdotnet Goto Github PK

View Code? Open in Web Editor NEW
355.0 48.0 132.0 3.89 MB

.NET interop library to call the R statistical language in the same process

License: MIT License

C# 93.43% F# 5.16% Shell 0.50% R 0.03% Batchfile 0.80% Dockerfile 0.08%
dotnet r interoperability embedded-scripting-language pinvoke

rdotnet's Introduction

R.NET

windows master: Build status master windows testing: Build status testing Linux master: Linux master Build Status Nuget Version

R.NET is an in-process bridge for the .NET Framework to access the R statistical language. R.NET works on Windows, Linux and MacOS.

License

MIT

Software requirements

On Windows, R.NET requires .NET Framework > 4.6.1 or .NET Core 2.0, and an access to the native R libraries installed with the R environment. R needs not necessarily be installed as a software on the executing machine, so long as DLL files are accessible (you may need to tweak environment variables for the latter to work, though) On Linux and MacOS, Mono is required, as well as an access to the native R libraries.

Getting started

As of 2017-08

  • If you want the latest binary distribution of R.NET and you are already familiar with managing dependencies with NuGet, head to R.NET on NuGet
  • If you need a bit more documentation to get started, the prefered entry point is at http://rdotnet.github.io/rdotnet

Building from source

Compiler toolchain foreword

Due to the move to targetting netstandard2.0, you might encounter compiling issue if using an older toolchain. This is machine dependent (mostly, which visual studio versions and .NET targetting packs you have). You may want to adapt the instructions from the rClr packge to avoid some pitfalls.

As an example:

  • where msbuild returns C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe should be the first line. C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe is probably not a good option.
  • msbuild -version returns 16.0.461.62831 or more recent
  • where dotnet: C:\Program Files\dotnet\dotnet.exe
  • dotnet --version: 2.1.602 or more. Note that this version of the .net core SDK would prevent compilation from VS2017: VS2019 required.
  • nuget help: 4.9.4.5839

Compiling

If using dotnet version prior to 2.1.3, installing/restoring prerelease dependency packages is problematic. You may need to use

nuget install -Prerelease DynamicInterop -OutputDirectory packages

otherwise:

nuget restore RDotNet.Tests.sln
dotnet build --configuration Debug --no-restore RDotNet.Tests.sln
# or if any issue possibly try:
# msbuild RDotNet.Tests.sln /p:Platform="Any CPU" /p:Configuration=Debug /consoleloggerparameters:ErrorsOnly

Windows, if you have several versions side by side:

set DN="C:\Program Files (x86)\dotnet\dotnet.exe"
%DN% build --configuration Debug --no-restore RDotNet.Tests.sln

Unit tests

Unit tests can be run using:

dotnet test RDotNet.Tests/RDotNet.Tests.csproj

Normally you should get something like:

Total tests: 92. Passed: 84. Failed: 0. Skipped: 8.
Test Run Successful.
Test execution time: 5.2537 Seconds

However note that from time to time (or at the first dotnet test execution) tests may fail to start, for reasons as yet unknown:

Starting test execution, please wait...
The active test run was aborted. Reason:
Test Run Aborted.

It may be that all subsequent calls then work as expected.

dotnet test RDotNet.FSharp.Tests/RDotNet.FSharp.Tests.fsproj

Building the nuget package

This section is primarily a reminder to the package author.

set B_CONFIG=Release
:: Or for initial testing/debugging substitute Debug for Release
:: set B_CONFIG=Debug

%DN% build --configuration %B_CONFIG% --no-restore RDotNet.Tests.sln

%DN% build R.NET/RDotNet.csproj --configuration %B_CONFIG% --no-restore
%DN% build RDotNet.FSharp/RDotNet.FSharp.fsproj --configuration %B_CONFIG% --no-restore

%DN% pack R.NET/RDotNet.csproj --configuration %B_CONFIG% --no-build --no-restore --output nupkgs
%DN% pack RDotNet.FSharp/RDotNet.FSharp.fsproj --configuration %B_CONFIG% --no-build --no-restore --output nupkgs

rdotnet's People

Contributors

davidpendraykalibrate avatar dcharbon avatar evolvedmicrobe avatar guillaumejamet avatar hyh avatar jmp75 avatar kierenj avatar kos59125 avatar lrasmus avatar skyguy94 avatar tongzhai avatar tpetricek avatar wei-lu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rdotnet's Issues

R.NET on 32bit machine - could not find function 'memory.limit'

I've developed a sample .NET Winform application which uses R.NET library to communicate with R.

Code is given below:

    private void button1_Click(object sender, EventArgs e)
    {
        var dir = AppDomain.CurrentDomain.BaseDirectory;

        var rPath = dir + ConfigurationManager.AppSettings["R_PATH"];
        var rHome = dir + ConfigurationManager.AppSettings["R_HOME"];

        try
        {
            REngine.SetEnvironmentVariables(rPath, rHome);
            engine = REngine.GetInstance();

            // A somewhat contrived but customary Hello World:
            CharacterVector charVec = engine.CreateCharacterVector(new[] { "Hello, R world!, .NET speaking" });
            engine.SetSymbol("greetings", charVec);
            engine.Evaluate("str(greetings)"); // print out in the console
            string[] a = engine.Evaluate("'Hi there .NET, from the R engine'").AsCharacter().ToArray();
            MessageBox.Show("R answered: "+ a[0]);

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

Output directory contains both "x64" and "i386" folders inside "R\bin" directory.

If I set Platform target to "x64" and run it on x64 machine, It works fine.

However, after changing the target plateform to "x86" or "Any CPU" when I run it on a 32bit machine, I get below error

Error: could not find function 'memory.limit'

I've noticed one more thing that when I call the REngine.GetInstance() second time after getting the above error message, it successfully returns the instance but then I get another error when engine.Evaluate("str(greetings)"); executes. The error is given below:

Error: could not find function 'str'

Any ideas please?

Environment/Library details:
Development machine: Windows 10 64bit
R.NET.Community: 1.6.5
.NET Framework: 4.6.1
R: R-3.3.2
Test Machine: Windows 10 32bit running as VM (Host: Windows 10 64bit)

RDotNet signed DLLs running on x64

I am trying to deploy RDotNet with my x64 project which uses signed DLLs. I was able to successfully sign the RDotNet dll so that my project ran but, when running i started getting an error saying DynamicInterop needed to be signed. Applied same steps as with RDotNet signing to sign DynamicInerop and now get the following error:

error CS0012: The type 'DynamicInterop.UnmanagedDll' is defined in an assembly that is not referenced. You must add a reference to assembly 'DynamicInterop, Version=0.7.4.0, Culture=neutral, PublicKeyToken=null'

The newly signed DynamicInterop is referenced in my project and copied to my run folder. Any ideas? appreciate any and all help. Thanks.

unable to evaluate histogram: Evaluation Exception

When I try to evaluate something like below I'm getting an exception. Could someone help me solve this problem.

hist(c(1,2,1,3,4,2,3,1,2,3,4,1,2,3,4,2,5,3,2,1,2,4,5,2,3,4,5,1,2,3,1,2,4,2,1,2))

I am getting the below error

Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-3.2.2/library/stats/libs/i386/stats.dll':
LoadLibrary failure: The specified module could not be found.

Request for official strongly-named assemblies

Hi,

I would like to check if there are any chances of getting an official NuGet package for RDotNet with signed, strongly-named assemblies out-of-the-box? Perhaps having two separate packages could be the best solution...

(For the record, I am aware that I can sign them myself... this is not the point of my request).

Cheers.

Still could not find function "t.test" after EnvironmentVariables correctly setted.

my code in asp.net mvc5:

            REngine.SetEnvironmentVariables("C:/Program Files/R/R-3.4.0/bin/i386" , "C:/Program Files/R/R-3.4.0")
            REngine engine = REngine.GetInstance();
            // REngine requires explicit initialization.
            // You can set some parameters.
            engine.Initialize();

            // .NET Framework array to R vector.
            NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 });
            engine.SetSymbol("group1", group1);
            // Direct parsing from R script.
            NumericVector group2 = engine.Evaluate("group2 <- c(29.89, 29.93, 29.72, 29.98, 30.02, 29.98)").AsNumeric();

            // Test difference of mean and get the P-value.
            GenericVector testResult = engine.Evaluate("t.test(group1, group2)").AsList();
            double p = testResult["p.value"].AsNumeric().First();

but i still got the error below:

RDotNet.EvaluationException: Error in t.test(group1, group2) : could not find function "t.test"

   在 RDotNet.REngine.Parse(String statement, StringBuilder incompleteStatement)
   在 RDotNet.REngine.<Defer>d__0.MoveNext()
   在 System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source)
   在 RDotNet.REngine.Evaluate(String statement)
   在 Microsoft.Scripting.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   在 Microsoft.Scripting.Interpreter.DynamicInstruction`4.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
   在 Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   在 IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   在 Dengdu.Areas.Core.Cache.DdPythonCache.Exec(CompiledCode code, IDictionary variables) 位置 D:\Users\dengdu\Products\Dengdu.Areas\Dengdu.Areas.Core\Dengdu.Areas.Core\Areas\Core\Root\Cache\Lazy\DdPythonCache.cs:行号 22
   在 Microsoft.Scripting.Interpreter.FuncCallInstruction`4.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   在 Microsoft.Scripting.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   在 Microsoft.Scripting.Interpreter.FuncCallInstruction`4.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   在 Microsoft.Scripting.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   在 Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   在 IronPython.Runtime.PythonContext.CallSplat(Object func, Object[] args)
   在 IronPython.Runtime.Operations.PythonOps.Invoke(CodeContext context, Object target, String name, Object[] args)
   在 Dengdu.Areas.Core.Controllers.UPythonController.FromApiRslt(String rel, Object rslt, String pymethod) 位置 D:\Users\dengdu\Products\Dengdu.Areas\Dengdu.Areas.Core\Dengdu.Areas.Core\Areas\Core\Controllers\UPythonController.cs:行号 56
   在 Dengdu.Areas.Core.Controllers.UPythonController.Api(String rel, String pymethod, String ff, String fv, String args, String data) 位置 D:\Users\dengdu\Products\Dengdu.Areas\Dengdu.Areas.Core\Dengdu.Areas.Core\Areas\Core\Controllers\UPythonController.cs:行号 32
   在 lambda_method(Closure , ControllerBase , Object[] )
   在 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   在 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

There is a bug in the FindRPaths code

If R_HOME is set in the Environment and rPath is empty is not, then FindRPaths function will skip the actual part of the code that sets rPath based on rHome. I've put a comment just before the part of the code that will not get run.

`

        if (string.IsNullOrEmpty(rHome))
        {
            rHome = GetRHomeEnvironmentVariable();
            doLogSetEnvVarInfo(string.Format("R.NET looked for preset R_HOME env. var. Found {0}",
               rHome == null ? "null" : rHome), logSetEnvVar);
        }
        if (string.IsNullOrEmpty(rHome))
        {
            rHome = FindRHome(rPath: null, logger: logSetEnvVar);
            doLogSetEnvVarInfo(string.Format("R.NET looked for platform-specific way (e.g. win registry). Found {0}",
               rHome == null ? "null" : rHome), logSetEnvVar);
            if (!string.IsNullOrEmpty(rHome))
            {

           // This code will not get run.

               if (rPath == null)
                {
                    rPath = FindRPath(rHome);
                    doLogSetEnvVarInfo(string.Format("R.NET trying to find rPath based on rHome; Deduced {0}",
                       rPath == null ? "null" : rPath), logSetEnvVar);
                }
                if (rPath == null)
                {
                    rPath = FindRPath();
                    doLogSetEnvVarInfo(string.Format("R.NET trying to find rPath, independently of rHome; Deduced {0}",
                       rPath == null ? "null" : rPath), logSetEnvVar);
                }
            }
            else
            {
                rHome = FindRHome(rPath);
                doLogSetEnvVarInfo(string.Format("R.NET trying to find rHome based on rPath; Deduced {0}",
                   rHome == null ? "null" : rHome), logSetEnvVar);
            }
        }

`

quantile function does not work

Hi,

I use R version 3.4.1
I use R.NET version 1.7.

It worked well until I use the quantile function
REngine r = REngine.GetInstance();
r.Evaluate("quantile()");
Error in quantile() : could not find function "quantile"

Is it a bug or am I doing wrong ?

Thank you,
Sébastien

RDotNet.Graphics.WPF

The RDotNet.Graphics library looks great, but it is only for WinForms. Do you have plans to implement same feature for WPF?

CurrentVersion parsing out of the Win32 registry

We are using the following R version: "3.5.2 Revised". The System.Version ctor throws an exception in NativeUtility.GetRVersionFromRegistry() because of the "Revised".

The following code solved my problem:

        /// <summary>
        /// Gets the R version from the Windows R Registry (if available)
        /// </summary>
        /// <returns>a System.Version object</returns>
        public static Version GetRVersionFromRegistry(StringBuilder logger = null)
        {
            var rCoreKey = GetRCoreRegistryKey(logger);
            string version = GetRCurrentVersionStringFromRegistry(rCoreKey);
            if (string.IsNullOrEmpty(version))
            {
                var subKeyNames = rCoreKey.GetSubKeyNames();
                if (subKeyNames.Length > 0)
                    version = subKeyNames[0];
            }
            for (int i = 0; i < version.Length; ++i)
            {
                if (!char.IsDigit(version, i) || version[i] != '.')
                {
                    version = version.Substring(0, i);
                }
            }
            return new Version(version);
        }

Proof: http://www.volatileread.com/utilitylibrary/snippetcompiler?id=68432

Occasional error in REngine.Parse on mono macOS

I occasionally ran into these error message when I evaluated an R statement (in my case, reading from an RDS and reading a data frame)

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) object.wrapper_native_0x108d612f0 (intptr) [0x00009] in <c9f8153c41de4f8cbafd0e32f9bf6b28>:0
  at RDotNet.REngine.Parse (string,System.Text.StringBuilder) [0x000cb] in <bfd52ca3b2dc45a6883203fa9f3ef2e8>:0
  at RDotNet.REngine/<Defer>d__46.MoveNext () [0x00097] in <bfd52ca3b2dc45a6883203fa9f3ef2e8>:0
  at System.Linq.Enumerable.TryGetLast<TSource_REF> (System.Collections.Generic.IEnumerable`1<TSource_REF>,bool&) [0x00049] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/external/corefx/src/System.Linq/src/System/Linq/Last.cs:76
  at System.Linq.Enumerable.LastOrDefault<TSource_REF> (System.Collections.Generic.IEnumerable`1<TSource_REF>) [0x00000] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/external/corefx/src/System.Linq/src/System/Linq/Last.cs:40
  at RDotNet.REngine.Evaluate (string) [0x00012] in <bfd52ca3b2dc45a6883203fa9f3ef2e8>:0
... my other code

But sometimes if got error stacktrace like the issue here: http://rdotnet.codeplex.com/workitem/154

The error only appears if:

  • Used on macOS with mono. My Windows PC with the same code run fine.
  • Non-assignment statement. e.g.
    Evaluate($"list$df").AsDataFrame()
    but not
    xx = Evaluate($"list$df").AsDataFrame()
  • 1 out of 10 attempts will run fine.

My machine:
MacBook Pro with Mono JIT compiler version 5.2.0.215
IDE: Jetbrains Rider or Visual Studio Community for Mac
RDotNet version 1.7.0

Vectors of NA values are parsed as boolean

We are using an R algorithm that usually should return a vector of doubles or NA values. Sometimes it returns a vector of NA values only ... e.g. c(NA, NA, NA, NA, NA)

For some reason, REngine.GetSymbol() would not return the NA-only vector as a list of doubles being Double.NaN (as I would expect), but as a list of Booleans being all "true".

Is this an issue with RDotNet or an issue with R's SEXPREC type? As RServe has similar behaviour, I suspect R itself.

(If my question seems weird: Sorry, I am new to R and RDotNet)

Versions used: RDotNet 1.5.5 / R 3.1.2

R.NET cannot initialize under IIS7 [EcologyRocks]

(This is forwarded from: EcologyRocks/TestRWebsite#1)
Hi coding experts, I met a really weird problem with R.NET in my web application project (c#.net), which might be interesting for some of you.

I want REngine to be initialized at start of my application and be closed when application is shutdown. I am doing so via Global.asax. It works as charm under my visual studio testing, but as soon as I use IIS7 to run my application, it gets stuck at engine.Initialize() and hanging there forever.

To test if it is a general problem with R.NET working with IIS7 under win server 2008 R2, I have created this default web form application: https://github.com/EcologyRocks/TestRWebsite. I used the source code rdotnet_e0329307d844 to debug within IIS processing. After the GetFunction()() get the function name successfully, visual studio process will go on to Callback function in RDotNet.Devices.CharacterDeniceAdapter, while IIS process just stuck here.

P.S.: lots of former posts have issued this as IIS cannot find R path and Rhome, but I tested with manually defined R path and Rhome and results are the same.

I will be really appreciated if you are interested in this topic, either can replicate it or give some hints. Many thanks!

ProtectedPointer usage

I see many SymbolicExpression are creating ProtectedPointer on themselves. If I read R manual correctly (link), Preserved objects are already immune to R's gc, so protecting them again is unnecessary. And ProtectedPointer calls Rf_unprotect_ptr, which also traverse an internal list just as R_ReleaseObject does. If the R.Net functions are synchronized, we can chage it to Rf_unprotect, which is much more efficient.

I think I can start to work on these issues. Of course this will require some code refactoring, but I will try to keep the library interface unchanged. @jmp75 , @skyguy94 , what do you think?

How to construct a native call to (..., pi = 3.14, e = 2.718)?

Currently, there are two options to invoke a function - either via an array of unnamed args or an IDictionary of name->value pairs. How to mix the two? What a native call I should use? I tested this in R:

> test <- function(...){print(names(list(...)))}
> test(1,2,3, x= 4)
[1] ""  ""  ""  "x"
> test <- function(..., x){print(names(list(...)))}
> test(1,2,3, x= 4)
NULL

In the former case x is not a part of ..., and I guess I need to pass two objects or some specially constructed object. Is there any example of such a call?

Running R-script in Azure function

Hi,

I'm working on setting up running of R-script in Azure function using Rdotnet.

This is the code that fails:

string rHome = @"D:\home\R-3.3.3";
string rPath = Path.Combine(rHome, @"bin\x64");
REngine.SetEnvironmentVariables(rPath, rHome);
REngine engine = REngine.GetInstance();
engine.Initialize();

This is the error I get:

Exception while executing function: RunRScript
Microsoft.Azure.WebJobs.Host.FunctionInvocationException :
Exception while executing function: RunRScript ---> System.Exception :
This 32-bit process failed to load the library R.dll. Native error message is '%1 is not a valid Win32 application'

Any suggestions on how to troubleshoot this issue?

Intermediate Objects Not Explictly Disposed

Many functions create temporary SymbolicExpression objects internally and leave them to the gc. I don't think this is good design for library code. Besides the added memory presure, this actually causes problems when R_ReleaseObject is called. This R API actually traverse the whole R_PreciousList to find the object to release, and what's worse, it does this Recursively!-- which cause StackOverflowException if the list gets too long. This means, the sooner we release an object, the less time it takes to locate the object in the list; and the more items in the list, the longer it takes to locate each of them, and the more likely you will get StackOverflowException. I always get this exception at R_ReleaseObject in StressTest, if n is large enough. I figure this is the cause.

Do not crash when R_Visible does not exist

As discussed in fslaborg/RProvider#152, in the GetVisible method, we have the following:

var symbol = DangerousGetHandle("R_Visible");
var value = Marshal.ReadInt32(symbol);
var result = Convert.ToBoolean(value);
return result;

With my version of R, the first call returns 0 and we get a nice access violation exception reading from the address 0 :-). PR with a fix coming soon!

RDotNet and R version 3.2.4

Has anyone else upgraded to R-3.2.4revised-win yet?

I'm getting an error when trying to SetEnvironmentVariables

REngine.SetEnvironmentVariables();

rCurrentVersionString from registry is coming back as "3.2.4 revised"

return new Version(rCurrentVersionStringFromRegistry); throwing system.format exception.

Any suggestions on a fix?

StackOverflowException with large number of Evaluate() invocations

I am trying to use RDotNet within a larger C# project. The issue that I see is this:
On executing a fairly large number of REngine.evaluate() commands, RDotNet (or R?) almost always throws StackOverflowException. (Of course, on windows, this kills the C# process.)

After some trial and error, I was able to reproduce this issue simply by repeatedly printing a line to a log file; StackOverflowException gets thrown often before completing log of 25-50k lines. The code snippet is below. (Of course, in my regular code, I cache the engine instance and dispose it later when I am done.)

Would appreciate any suggestions/pointers..

Notes:

  • Environment: windows 7 Pro; .Net 4.6 (build target of 4.5); R 3.1.1; R.NET 1.6.5;
  • I was NOT able to reproduce this on a stand-alone project that has only RDotNet even after printing 5 million lines.
  • Occasionally, especially when I write fewer lines, the StackOverflowException gets thrown after the loop below completes and execution moves on to something else. Does this point to any cleanup-related issues in R or R.Net? Possibly related to #8?
  • I have also tried executing gc() every 100 invocations, for example. Still get the StackOverflowException.
[MethodImpl(MethodImplOptions.Synchronized)]
public void Initialize(){

   // get engine instance
   REngine.SetEnvironmentVariables();
   REngine engine = REngine.GetInstance();
   engine.Initialize();

   // open a log file
   var logFileInfo = new FileInfo("r.log");
   var rCmd = @"sink('" + logFileInfo.FullName.Replace("\\", "\\\\") + "')";
   engine.Evaluate(rCmd);

   // write lines to log file
   string newLine = @"""\n""";
   for (int i = 1; i <= 50000; i++)
   {
      engine.Evaluate(string.Format("cat(date(), \" Line # {0}\", {1})", i, newLine));
   }
}

The library is not thread safe.

Calling it in concurrent threads is likely to crash, even if user synchronizes the calls at higher level. The lock in Preserve/Unpreserve functions doesn't really help because: 1. it can be called in gc threads concurrently with other R API functions since they are not locked, both R API and the GetFunction() utility are not thread safe; 2. if user explictly calls Unpreserve, R_ReleaseObject can be invoked second time since the lock is inside the flag checking.

I think the solution is to use engine-wide lock to synchronize every R API invocation. The locking overhead should be neglectable comparing to the expensive R API invocations. I've tested with this change and I think the library is thread safe now. It can pass the MultiThreadingTest and StressTest with no problem. The hack on CStackLimit can also be dropped after this change. I can push the change to some branch if someone is interested.

R.Net fails to Load stats library when running on IIS

I'm trying the webapplicationsample WebApplicationRdn and whenever i try to use kmeans or lm i get the following (error unable to load shared object 'K:/Program Files/R-3.2.3/library/stats/libs/i386/stats.dll': LoadLibrary failure: The specified module could not be found.) did i miss a configuration step or something. If i run the same on a console application instead of a web one it goes smooth as silk.

cast Matrix to 2d array

Firstly, it seems i cannot cast CharacterMatrix to string(,)

Second, NumericMatrix to Double(,) does not handle NA correctly:
suppose
ma=matrix(0.1,3,3);ma[1,2]=NA
and then r is the matrix result:
Dim mym As NumericMatrix = r.AsNumericMatrix
Dim currentdfarray1 As Double(,) = mym.ToArray
somerange.Value = currentdfarray1

it writes to excel successfully, but ma[1,2] is shown as 65535 instead of empty

Exception in case registry values not installed during installation of R

When installing R without checking the option to save the R version in the registry, REngine.GetInstance("path here") fails with exception message:

Windows Registry key 'SOFTWARE\R-core' not found in HKEY_LOCAL_MACHINE nor HKEY_CURRENT_USER

Stacktrace:

at RDotNet.NativeLibrary.NativeUtility.GetRCoreRegistryKeyWin32()
at RDotNet.NativeLibrary.NativeUtility.FindRHome(String rPath)
at RDotNet.NativeLibrary.NativeUtility.SetEnvironmentVariables(String rPath, String rHome)
at RDotNet.REngine.SetEnvironmentVariables(String rPath, String rHome)
at RDotNet.REngine.GetInstance(String dll, Boolean initialize, StartupParameter parameter, ICharacterDevice device)

This key seems to be used for determining the R location and the R version. In case neither are provided in GetInstance - I can imagine why the exception needs to be thrown.

However - I've provided the DLL file location in GetInstance. Then probably it's not necessary if the registry key cannot be found - so that the R version couldn't be determined, right?

Incorrect working of "track" library under R.NET

Hello.

I found one problem when tried to work with "track" package. I really can't understand the reason of it, but...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RDotNet;
using RDotNet.NativeLibrary;
using RDotNet.Dynamic;

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            var engine = REngine.GetInstance();

            engine.Initialize();

            engine.Evaluate("library(track);");
            engine.Evaluate(@"track.start(clobber = ""vars"", dir = file.path(tempdir(), 'rdata12356'))");

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

            Console.ReadLine();
        }
    }
}

track.summary() doesn't work properly via R.NET.
This is execution result via R.NET:
Tracking (writable) using existing directory 'rdatadir'
[1] class mode extent length size modified TA TW
<0 строк> (или 'row.names' нулевой длины)
[1] "a"
This is execution result via R-3.2.2.x64

library(track);
track.start(clobber = "vars", dir = file.path(tempdir(), 'rdata123'));
Tracking (writable) using new 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-18 20:36:23 0 1
print(ls(globalenv()));
[1] "a"

track.stop();
Stopping tracking on

What's the reason of this difference in working?

Thank you.

System.UInt64 support

Hi,
When I was using RClr and got following error:

> clrGetMemberSignature(spec_obj, 'defaultArrayLength')
[1] "Property defaultArrayLength, UInt64, can write: True"
> clrGet(spec_obj, 'defaultArrayLength')
Error in (function ()  : 
  clr_obj_ms_convert_to_SEXP: COM variant type code 21 unsupported. Returning NULL
Error in clrCallStatic(clrFacadeTypeName, "GetFieldOrProperty", objOrType,  : 
  Type:    RDotNet.EvaluationException
Message: Error in (function ()  : 
  clr_obj_ms_convert_to_SEXP: COM variant type code 21 unsupported. Returning NULL

Method:  RDotNet.ProtectedPointer evaluateCall(IntPtr)
Stack trace:
   at RDotNet.Function.evaluateCall(IntPtr call)
   at RDotNet.Function.createCallAndEvaluate(IntPtr argument)
   at Rclr.RDotNetDataConverter.CreateClrObj(Object obj) in c:\Users\hhusl\AppData\Local\Temp\RtmpWMoV35\R.INSTALL337439456109\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 603
   at Rclr.RDotNetDataConverter.TryConvertToSexp(Object obj) in c:\Users\hhusl\AppData\Local\Temp\RtmpWMoV35\R.INSTALL337439456109\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 320
   at Rclr.RDotNetDataConverter.ConvertToR(Object obj) in c:\Users\hhusl\AppData\Local\Temp\RtmpWMoV35\R.INSTALL337439456109\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 220
   at Rclr.ClrFacade.marshallDataToR(Object obj, Boolean tryUseConverter) in c:\Users\hhusl\AppData\Local\Temp\RtmpW

I believe this is because RClr (essentially R.NET) doesn't support the type System.UInt64. Could you help me to fix that? Thanks a lot!

NULL value

my C# datable contains NULL,when setsymbol,the NULL values turned to 0 or "" automatically?any way to get R NULL?

Cannot find function rnorm.

I cannot run this command: "x <- rnorm(1000)" in R.net

When I execute this statement:

engine.Evaluate("x <- rnorm(1000)")

I get an error "Cannot find function rnorm."

creating a graphics device RdotNet

Hi,
I want to create graphics device but not want to use any graphics library from dotnet just want to utilize RDotnet sources. is it possible?
could you help me?
Thanks

# symbol parsing

Since release of version 1.6 "#" symbols are not parsed. For instance, RManager.Engine.Evaluate("print('#something')") does not print anything. It creates a lot of problems, since it is not possible to use color codes in ggplot2 anymore (i.e. "#E69F00"). Also knitr stop working because it cannot parse headers in the format "### Header text".

It seems the problem occurs due to changes in commit 8387202:

private static IEnumerable Segment(string line)
         {
-            var segments = line.Split(';');
+            // Fix for
+            // https://rdotnet.codeplex.com/workitem/165
+            string[] commentsSegments = line.Split('#');
+            string uncommentedStatements;
+            if (commentsSegments.Length == 0)
+                uncommentedStatements = string.Empty;
+            else
+                uncommentedStatements = commentsSegments[0];
+
+            var segments = uncommentedStatements.Split(';');

Error in library(data.table) : there is no package called 'data.table'

We have created a webservice on IIS which calls a R script. The R script includes some libraries like: data.table, caret and few a more. R is returning an error that it cannot find the data.table library: "Error in library(data.table) : there is no package called 'data.table'".

We confirmed that the data.table package is installed in: "C:\Program Files\R\R-3.3.3\library\data.table". When we run .libPaths() to check where R tries to load the libraries from, it returns that this is the folder "C:/Program Files/R/R-3.3.3/library".

It does work successfully in a Visual Studio 2017 unit test or even in a console application environment. So the question is why can't R load the data.table library within IIS?

We using the following software versions:

  • R for Windows 3.3.3
  • Internet Information Services version 10.0.14393.0
  • RDotnet community 1.6.5

C# code:

R = REngine.GetInstance();
R.Initialize();
R.Evaluate("install.packages('data.table', repos='http://cran.us.r-project.org', dependencies = TRUE)");
R.Evaluate("library(data.table)");

Reading from file causes AccessViolationException

When you try to Evaluate a line calling read.csv, the application crashes with an AccessViolationException. Copying the same command into RStudio and running it there correctly loads the file into a dataframe.

Code to reproduce, where rawFileName is a regular Windows path to a csv file.

 dataFileName = rawFileName.Replace(@"/", @"//"); 
 string loadDataCommand = String.Format(@"userData <- read.csv('{0}')", dataFileName);
 this.engine.Evaluate(loadDataCommand);

Running any other type of R code in the same place causes no errors, but any attempts to read a file cause the application to crash and complain about attempted access to restricted memory.

about the exception:environment variable name or value is too long

question:
The program constantly calls a function which using rdotnet to calculate something for forcast nearly five miniutes at a time.
And the exception named environment variable name or value is too long occurs Once a month.
Anybody can help?It tortures me for months.

R version:R x64 3.2.2 for Windows

RDOTNET version:1.6.5.0

implements code in the function:
REngine engine=null;

REngine.SetEnvironmentVariables();
// There are several options to initialize the engine, but by default the following suffice:
engine = REngine.GetInstance();

NumericVector congestionindex = engine.CreateNumericVector(input);
engine.SetSymbol("xxxx", xxxx);
engine.Evaluate("source('" + areaRdocPath[(int)areaType] + "')");
engine.Evaluate("output_short<-short_predict(xxxx," + xxx+ ")");
double[] output_short = new double[5];
output_short[0] = engine.GetSymbol("output_short").AsNumeric().ElementAtOrDefault(0);
......

//engine.Dispose();
return xxxx;

REngine.GetInstance() method goes in infinite loop after building application.

I am using R.Net with my web application. I have hosted site in IIS 7 and written below simple code on click event of a button

protected void btnGetData_Click(object sender, EventArgs e)
{
    //Get instance of REngine
    REngine.SetEnvironmentVariables();
    engine = REngine.GetInstance();
}

My problem is, above code works fine for first time, but when I rebuild my solution then again run the same page, then the line engine = REngine.GetInstance(); goes into infinite loop.
I have also tried using engine.Dispose() method, but then it gives below error.

The single REngine instance has already been disposed of (i.e. shut down). Multiple engine restart is not possible.

Can any body please help me out?.

RMD files not working

When I run this code using the Rdotnet library:

engine.Evaluate("rmarkdown::render(rmd_filename)").ToString());

I get a stackoverflow error. I have tried various ways. Even this statement below gives the same error:

engine.Evaluate("source('/sourcefile.r')")

Resizing plots generated from console using R.Net causes application to crash

I also ran into this issue with a F# console application. The code works as expected when evaluated in the F# Interactive window, but crashes when attempting to zoom or resize the device window when the application is run.

I've published some code that reproduces this issue on my machine here:
https://rdnetwi153.codeplex.com/

Let me know if you need any other information.

OS: Windows 8.1
.NET 4.5
R.NET.Community 1.5.20
DynamicInterop 0.7.2.0

Setup in VS2013:
New project (FSharp > Console Application)
NuGet -> Install-Package R.NET.Community

Values messed up when converting big data structure to a Dataframe

I've come across an issue while transforming large amounts of data (in volume and weight) to a Dataframe while using REngine.CreateDataFrame on a console application. It works well when the dataset is small, but when I get to a certain variable amount it starts behaving weirdly. I've even recieved a AccessViolationException on certain computers while calling the Rf_MkChar function.

For example, the most common thing I've encountered its that it mixes up data in the same column:

The data I supply to the method: [1, 2, 3, 4, 5, 6]
The data that goes out of the method: [1, 2, 3, 2, 5, 6]

This only happens with large amounts of data. On a 8 columns * 10k rows dataframe it behaves as expected, but for example, when those rows get to 600k it will mess up the data. We'll get duplicates, but no empty or "NA" entries.

By now I've been able to circumvent this issue by serializing the data to CSV and loading it after with a readCsv(). That works fine and no duplicates are found when running the R script.

My specs are:
R Version: 3.3.3
R.NET Version: 1.7
Memory: 32GB
SO: Windows 10 or Windows Server 2012 (64 bit)

RDotNet1.6.5 Issue in Engine.evaluate()., application error happens

Executing R code using RDotNet 1.6.5 , and the web api application pool crashes when multiple people uses it and no error was displayed in R source code. Attached below is the stack trace of the R web app.
Though the application doesn't behave as expected it continues to function but get errors occasionally.
stacktrace.txt

Stack Trace
System.AccessViolationException 1 Attempted to read or write protected memory. This is often an indication that other memory is corrupt. RDotNet.ProtectedPointer.Dispose()
RDotNet.REngine.Parse(System.String, System.Text.StringBuilder)
RDotNet.REngine+d__0.MoveNext()
System.Linq.Enumerable.LastOrDefault[System.__Canon, mscorlib]
RDotNet.REngine.Evaluate(System.String)
AgileAnalyticsWebAPI.Models.RModel.ProcessRCodeAgileAPI(Int64, System.String, Int32, Int64, System.DateTime, Int32)
AgileAnalyticsWebAPI.Controllers.AgileAPIController.GetAgileAPIPrediction(Int64, System.String, Int32, Int64, System.DateTime, Int32)
DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, System.Object, System.Object[])
System.Web.Http.Controllers.ReflectedHttpActionDescriptor+ActionExecutor+<>c__DisplayClass10.b__9(System.Object, System.Object[])
System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(System.Web.Http.Controllers.HttpControllerContext, System.Collections.Generic.IDictionary2<System.String,System.Object>, System.Threading.CancellationToken) System.Web.Http.Controllers.ApiControllerActionInvoker+<InvokeActionAsyncCore>d__0.MoveNext() System.Runtime.CompilerServices.AsyncTaskMethodBuilder1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Controllers.ApiControllerActionInvoker+d__0, System.Web.Http]](d__0 ByRef)
System.Web.Http.Controllers.ApiControllerActionInvoker.InvokeActionAsyncCore(System.Web.Http.Controllers.HttpActionContext, System.Threading.CancellationToken)
System.Web.Http.Controllers.ApiControllerActionInvoker.InvokeActionAsync(System.Web.Http.Controllers.HttpActionContext, System.Threading.CancellationToken)
System.Web.Http.Controllers.ActionFilterResult+d__2.MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Controllers.ActionFilterResult+<ExecuteAsync>d__2, System.Web.Http]](<ExecuteAsync>d__2 ByRef) System.Web.Http.Controllers.ActionFilterResult.ExecuteAsync(System.Threading.CancellationToken) System.Web.Http.ApiController.ExecuteAsync(System.Web.Http.Controllers.HttpControllerContext, System.Threading.CancellationToken) System.Web.Http.Dispatcher.HttpControllerDispatcher+<SendAsync>d__1.MoveNext() System.Runtime.CompilerServices.AsyncTaskMethodBuilder1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Dispatcher.HttpControllerDispatcher+d__1, System.Web.Http]](d__1 ByRef)
System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
System.Web.Http.Cors.CorsMessageHandler+d__5.MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Cors.CorsMessageHandler+<HandleCorsRequestAsync>d__5, System.Web.Http.Cors]](<HandleCorsRequestAsync>d__5 ByRef) System.Web.Http.Cors.CorsMessageHandler.HandleCorsRequestAsync(System.Net.Http.HttpRequestMessage, System.Web.Cors.CorsRequestContext, System.Threading.CancellationToken) System.Web.Http.Cors.CorsMessageHandler+<SendAsync>d__0.MoveNext() System.Runtime.CompilerServices.AsyncTaskMethodBuilder1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Cors.CorsMessageHandler+d__0, System.Web.Http.Cors]](d__0 ByRef)
System.Web.Http.Cors.CorsMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
System.Web.Http.HttpServer+d__0.MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1[[System.__Canon, mscorlib]].Start[[System.Web.Http.HttpServer+<SendAsync>d__0, System.Web.Http]](<SendAsync>d__0 ByRef) System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) System.Web.Http.Owin.HttpMessageHandlerAdapter+<InvokeCore>d__0.MoveNext() System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.Web.Http.Owin.HttpMessageHandlerAdapter+<InvokeCore>d__0, System.Web.Http.Owin]](<InvokeCore>d__0 ByRef) System.Web.Http.Owin.HttpMessageHandlerAdapter.InvokeCore(Microsoft.Owin.IOwinContext, Microsoft.Owin.IOwinRequest, Microsoft.Owin.IOwinResponse) Thinktecture.IdentityServer.AccessTokenValidation.ScopeRequirementMiddleware+<Invoke>d__0.MoveNext() System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Thinktecture.IdentityServer.AccessTokenValidation.ScopeRequirementMiddleware+<Invoke>d__0, Thinktecture.IdentityServer3.AccessTokenValidation]](<Invoke>d__0 ByRef) Thinktecture.IdentityServer.AccessTokenValidation.ScopeRequirementMiddleware.Invoke(System.Collections.Generic.IDictionary2<System.String,System.Object>)
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__5.MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__5, Microsoft.Owin.Host.SystemWeb]](d__5 ByRef)
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.RunApp(System.Func2<System.Collections.Generic.IDictionary2<System.String,System.Object>,System.Threading.Tasks.Task>, System.Collections.Generic.IDictionary2<System.String,System.Object>, System.Threading.Tasks.TaskCompletionSource1<System.Object>, Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult)
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent(System.Object, System.EventArgs, System.AsyncCallback, System.Object)
System.Web.HttpApplication+AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)

IIS 10 deploy Rdotnet Issue

Hi All,

I am facing deployment issues in IIS 10
Error in library(RODBC) : there is no package called 'RODBC' same with other packages also.
Tried changing path also but nothing works for me
But in VS2015 its working fine

Thanks

Unicode Character suport

Hi
I am trying to read an excel file using hadley's readxl R package.
When I try to display the data, I found that two of my entries got displayed wrongly as if there is no unicode character support.

First columns in last 2 rows are incorrectly displayed text. The correct text should be :
O’Donnell
and
Pérez-Olaeta
respectively.
Please let me know how to fix this.

I have attached an excel file and I used following code to read it.
//// Code begins /////
REngine.SetEnvironmentVariables();
REngine engine = REngine.GetInstance();

        //// using hadley's readxl
        engine.Evaluate("library(readxl)");
        engine.Evaluate("df2 <- read_excel('Unicode.xlsx')");
        DataFrame DF2 = engine.Evaluate("df2").AsDataFrame();
        if (DF2 != null)
        {
            StringBuilder sb2 = new StringBuilder("\n");
            int rc = DF2.RowCount;
            int cc = DF2.ColumnCount;
            for (int i = 0; i < rc; i++)
            {
                for (int j = 0; j < cc; j++)
                {
                    sb2.Append("\t" + DF2[i, j]);
                }
                sb2.Append("\n");
            }
            // output2.Text = sb2.ToString(); //this is textbox or textblock control in WPF/C#
        }
        engine.Dispose();

//// Code ends /////

//// Excel File attachment////
Unicode.xlsx

//Here is the screenshot ///see the first column of the last 2 rows ///
unicodeissue

Thanks and Regards,
adpgithub

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.