Giter Site home page Giter Site logo

rservecli2's Introduction

Build status NuGet version

Overview

RserveCLI2 is a .NET/CLR client for Rserve. It allows .NET/CLR client to access R on the same machine or across the network.

Details

Rserve (http://www.rforge.net/Rserve/) is a server application that allows users to access an R (http://www.r-project.org/) session remotely across the network. RserveCLI2 is a client library that allows one to access an Rserve server from a .NET/CLR environment using languages such as C#, Visual Basic, etc.

Fork of RserveCLI

  • This is a fork of RserveCLI, by Oliver M. Haynold which is hosted here: https://rservecli.codeplex.com
  • Forked at commit 14449
  • I wanted to add features and fix bugs unencumbered by the author's bandwidth
  • I'm targeting Visual Studio 2010 and the 3.5 framework (dropping Mono Develop)

Added Features

  • Greatly improved testing framework: testing against R/Rserve is now self-contained in the Test project (integration tests become unit tests!)
  • Bi-directional support for Date type
  • Read matrix as a 2d array
  • Create SEXP from decimal
  • Can now create usable data.frames
  • Bi-directional support for matrix row/column names
  • Can now make named vectors
  • Now supports sending and receiving large data (>16MB)

rservecli2's People

Contributors

atifaziz avatar dependabot-preview[bot] avatar kent37 avatar konne avatar lahma avatar surajgupta 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

Watchers

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

rservecli2's Issues

Are we targeting CLI or CLR?

This project is not guaranteed to work with Mono. The goal is for a robust and stable library that works on Windows. Is the project better named CLR?

Build failing on AppVoyer

Looks like building on AppVoyer is failing after checking in the async support and I believe it's because the C# compiler version being invoked by MSBuild does not understand the C# 6 syntax.


[00:00:00] Build started
[00:00:00] git clone -q --branch=async https://github.com/SurajGupta/RserveCLI2.git C:\projects\rservecli2
[00:00:05] git checkout -qf cc6b9b0874a5e998bc90ae32020cbc36d3995e50
[00:00:05] Patching AssemblyInfo
[00:00:05] Patching RServeCLI2\AssemblyInfo.cs...
[00:00:06] OK
[00:00:06] Patching RServeCLI2.Example\Properties\AssemblyInfo.cs...
[00:00:06] OK
[00:00:06] Patching RServeCLI2.Test\Properties\AssemblyInfo.cs...
[00:00:06] OK
[00:00:06] nuget restore
[00:00:07] msbuild "RserveCLI2.sln" /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
[00:00:07] Microsoft (R) Build Engine version 12.0.31101.0
[00:00:07] [Microsoft .NET Framework, version 4.0.30319.34209]
[00:00:07] Copyright (C) Microsoft Corporation. All rights reserved.
[00:00:07] 
[00:00:09] RConnection.cs(183,88): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(184,18): error CS1519: Invalid token '!=' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(184,38): error CS1519: Invalid token '!=' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(184,52): error CS1520: Method must have a return type [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(184,74): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(184,84): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(184,86): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(211,115): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(212,35): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(212,36): error CS1520: Method must have a return type [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(212,57): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(212,63): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(212,76): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(212,77): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(251,121): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(252,35): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(252,36): error CS1520: Method must have a return type [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(252,53): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(252,59): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(252,72): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(252,73): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(335,56): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(336,35): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(336,37): error CS1520: Method must have a return type [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(336,57): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(336,63): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(336,65): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(347,61): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(348,35): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(348,51): error CS1519: Invalid token ',' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(348,66): error CS1519: Invalid token '{' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(348,75): error CS1519: Invalid token ',' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(348,81): error CS1519: Invalid token '}' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(348,83): error CS0116: A namespace cannot directly contain members such as fields or methods [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(359,16): error CS1518: Expected class, delegate, enum, interface, or struct [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(371,22): error CS1518: Expected class, delegate, enum, interface, or struct [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(373,67): error CS1518: Expected class, delegate, enum, interface, or struct [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(373,74): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(373,76): error CS1518: Expected class, delegate, enum, interface, or struct [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(373,82): error CS0116: A namespace cannot directly contain members such as fields or methods [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(375,33): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] RConnection.cs(376,9): error CS1022: Type or namespace definition, or end-of-file expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(15,78): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(16,13): error CS1520: Method must have a return type [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(16,29): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(16,37): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(16,52): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(18,88): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(19,13): error CS1520: Method must have a return type [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(19,29): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(19,37): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(19,39): error CS1031: Type expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(19,46): error CS1519: Invalid token ')' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(21,100): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(22,13): error CS1520: Method must have a return type [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(22,29): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(22,37): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(22,45): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(22,51): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(22,69): error CS1001: Identifier expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(38,81): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(39,32): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(39,39): error CS1519: Invalid token ',' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(39,54): error CS1519: Invalid token ')' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(41,91): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(42,32): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(42,39): error CS1519: Invalid token ',' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(42,48): error CS1519: Invalid token ',' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] SocketExtensions.cs(42,66): error CS1519: Invalid token ')' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] TaskExtensions.cs(30,92): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] TaskExtensions.cs(31,32): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] TaskExtensions.cs(31,58): error CS1519: Invalid token ':' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] TaskExtensions.cs(33,83): error CS1002: ; expected [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] TaskExtensions.cs(34,32): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] TaskExtensions.cs(34,58): error CS1519: Invalid token ':' in class, struct, or interface member declaration [C:\projects\rservecli2\RserveCLI2\RserveCLI2.csproj]
[00:00:09] Command exited with code 1

Code Formatting (Standards)

Would be good to follow general .NET coding standards. The code currently fails validation if you are using something like stylecop. There are lots of spacing issues:

For instance:

    public override Sexp this[ int index ]
    {
        get
        {
            return new SexpArrayBool( Value[ index ] );
        }

        set
        {
            Value[ index ] = value.AsBool;
        }
    }

Should really be:

    public override Sexp this[int index]
    {
        get
        {
            return new SexpArrayBool(Value[index]);
        }

        set
        {
            Value[index] = value.AsBool;
        }
    }

It's only a small issue but when part of a larger builds source code will make integration less of an issue if the original code follows the established guidelines.

Inappropriate error message in AsString

Using the propery AsString on the return value of Eval may result in the following message:

Can only convert numeric arrays of length 1 to double.

This is confusing, as I do not request a double.

I had this issue when I was receiving a list of strings and had to use AsStrings in stead.

Connect to Existing R Process

I've been attempting to adapt the code to allow it to connect to an existing RTerm process rather than spinning up a new one and disposing it immediately after execution. Seems this isn't as simple as it sounds to do reliably. Any ideas on how this might work in practice would be interesting.

Catching R Graphics Window

Hi, Suraj, good to know that someone is continuing work on RserveCLI. I am using RDotnet, but I believe that the combination with RServe is the better choice in the long run, because the people behind Rserve are a well-established team, while RDotnet is virtually abandoned.

My main reason for still working with RDotnet is graphics; I have managed to capture the R-Graphics file, and have all features of it available, e.g. using the right mouse button to save the plot in different formats.

See http://rdotnet.codeplex.com/workitem/7 for the code.

Because of these features, I much prefer this method to the alternative of generating a png file, and import it; I found some Java code floating around doing it that way.

However, as I see there is nothing stopping us from using the hook-code I used for RDotnet for RServe. I am currently working on projects with higher priority, but if you want to give it a try...

Dieter

Compile error

Hi!
Thank you for your precious work.
I opened the solution with VS2012 and by compiling I get 133 errors
How can I fix it?
Thank you

Consider Signing / Strongly Naming the Assembly

I'm referencing RserveCLI2 in an assembly that I need to sign and load into my GAC. I notice that at least the version of RserveCLI2 that I have (mine is in folder RserveCLI2.1.0.21.0) is not signed, and so my referencing assembly can't be signed. This can be worked around but I understand it's better practice to request that the original developers sign it. I'm very new to Rserve, RserveCLI2, and to having to sign and load assemblies into the GAC, so please let me know if there's a better solution. Also very new to GitHub, so please let me know if there's a better way to mentioning the problem.

Method documentation is insufficient for Shuwdown operations

I am confused by the 4 methods related to shutting down:

- public void Shutdown()
- public Task ShutdownAsync()
- public void ServerShutdown()
- public Task ServerShutdownAsync()

Are the following observations correct?

  1. After some fiddlig, I found out that Shutdown() shuts down the parent RServe process and the forked child processes. ServerShutdown() shuts down only the child process for the connection it is being called upon.
  2. ServerShutdown() has a comment "This command is asynchronous!", but this is not actually run asynchronously.

Treat warnings as errors

Following on from the comment as part of issue #30:

I'm adamant that we maintain "Treat Warnings as Errors" when building. I think Warnings are a weird concept - if the compiler guys are warning you, you should be worried. Almost every .net project that I've worked on in the past decade has had that setting enabled and I've never regretted it.

I'm absolutely fine on this as long as we suppress warning CS1591, “Missing XML comment for publicly visible type or member…”. When XML docs generation is on and any members of the public API are not documented then those warnings become errors and you can't build, experiment and spike anymore. It kills the speed of your thought & drains creative juices.

Best practices for starting and stopping Rserve?

Hi, I would like to start and stop Rserve from within my client application. similar to what RServeCLI2.Test does in Rservice.cs. Is that a good starting point or is there a better way to do this?

Also, why don't you use CmdCtrlShutdown to stop the server, rather than forcing RTerm to keep running?

Thanks for your work, this looks like a great project!

Unable to load R script using eval

I have a R script on the server which has some functions in it. I want to load those functions into Rserve and use them in the eval. But when I load the script using source it fails.

Is there a way to load external script into rserve and use the functions defined in it.

s.VoidEval(string.Format("source("{0}")", scriptPath));
var data = s.Eval(string.Format("processInput("{0}")", csvPath));

RserveCLI2 can't handle 'as.factor'

When executing the following piece of code, it produces different results in R en RserveCLI2:

RConnection s = initRConnection(port:6311);
s.VoidEval("library('data.table')");
s.VoidEval("test <- data.table(c(200,200,205)");
Console.WriteLine(s["as.data.frame(test[, lapply(.SD, as.factor), .SDcols=c('V1')])"].ToString());

In R, the result is handled as 'factors' and produces [200,200,205].
In RserveCLI2 however, it seems the result is casted with 'as.numeric' because it produces [1,1,2].

Why does RserveCLI casts this as numeric? (or is something else going on?)
Doesn't it support factor?
Is this a bug?

regards,

How to connect remote server use SSH

Hi,

I am using RserveCLI connect Rserve server, but don't want to connect it through username and password, Is it possible connect it using SSH?

Many thanks.
Jack Wang

RserveCLI2

What do I do to run the RServeSample, please?

System.Net.Sockets.SocketException was unhandled
HResult=-2147467259
Message=No connection could be made because the target machine actively refused it 192.168.0.13:6311
Source=System
ErrorCode=10061
NativeErrorCode=10061

Thanks.

Calling RServe using ThreadPool

I have been looking this over and I cannot seem to figure out if this is possible:

1.) Can I call RServe rapidly with different threads from C# ThreadPool? When I try to do it, I seem to be getting this error result:
"Additional information: Recieved an unknown command parameter type from the server:16."

2.) Is there another way I should do this? Should I attempt to launch a few RServe daemons and then send multiple requests to each?

I'm attempting to send multiple lists of a window of 200 numbers to do the same calculation. Basically I save 210 numbers, and then want to pass data with these indices to perform the same calculation (sliding 200 length window of data points): I send these "in parallel"-
[0:199]
[1:200]
[2:201]
[3:202]
etc.

*IF I do these calculations "in line" where the first blocks the rest (without the ThreadPool or using Threading of some sort) my calculation might be too slow. I appreciate your help.

Thanks,
Mike P. Sopko

How to compile RserveCLI2 with SharpDevelop 4/5

I tried to compile RserveCLI2 using SharpDevelop 5.1 RC / 4.3 , but it seemed that NET Framework compiler didn't understand the following line :


        internal static void NotifyUnhandledException(this Task task) =>
            OnUnhandledException(new UnhandledTaskExceptionEventArgs(task));

Report specific RServe exceptions

Right now we just throw a generic WebException when the server tell us that there was a problem. We should parse out the exact error and report that.

large data is not supported

Rserve v .3 added support for large data but RserveCLI2 does not implement that feature. This limits datasets to 16mb. Here's the info from the Rserve website that should be used to make the fix:

"Rserve version 0.3 reports ID string version 0102 because support for large data was added. Previous versions were limited by the 24-bit length of parameters and SEXPs. The 0.3 version enhances the protocol by adding special flag DT_LARGE to parameter types and XT_LARGE to eXpression types. If this flag is set then the header is 8 bytes long (instead of previously 4 bytes). The additional 4 bytes are used for the parameter/expression length leading to a total of 56-bit maximum length of an expression or parameter (that is 65536TB which should be sufficient). Any data smaller 0x800000 (8MB) must be still coded in the original 4-byte header format. Current Rserve sends only data larger 0xfffff0 (16MB-16) in the large data format. Clients are encouraged to use the same threshold, but it's not required by the protocol."

serverErrorCode 47, Trying to run your Rserve.Example.cs

I have R 3.0.2 installed with package Rserve running on CentOS.

I have tried to run the example RserveCLI2 with my amendments to log into my Rserve.

using ( var s = new RConnection( new System.Net.IPAddress( new byte[] { 10 , 0, 0, 124 } ) , port: 6311 , user: "antin" , password: "hadoop" ) )

What am I doing wrong?

Exception reading list responses from server

When I try to evaluate this simple command
var list = s.Eval("list(a=1)");

I get this Exception
RserveCLI2.RserveException: 'Response from server does not contain a header.'

Runig with latest R (3.5.1)

The factor integers are not recognized

Use datasets::HairEyeColor

You will receive bunches of ints instead of strings. This is my proposed fix:
in Qap1.cs, line 744 replace with this:

            case XtArrayInt:
                {
                    var res = new int[length / 4];
                    var intBuf = new byte[4];
                    for (long i = 0; i < length; i += 4)
                    {
                        Array.Copy(data, start + i, intBuf, 0, 4);
                        res[i / 4] = BitConverter.ToInt32(intBuf, 0);
                    }

                    result = null;
                    string[] classAttribute;
                    if (attrs != null
                        && attrs.ContainsKey("class"))
                    {
                        classAttribute = attrs["class"].AsStrings;
                        if (classAttribute.Contains("Date"))
                        {
                            // Treat as dates
                            result = new SexpArrayDate(res);
                        }

                        // Treat as strings
                        if (attrs.ContainsKey("class"))
                        {
                            string[] levels = attrs["levels"].AsStrings;
                            result = new SexpArrayString();
                            foreach (int levelIndex in res)
                            {
                                result.Add(levels[levelIndex - 1]);
                            }
                        }
                    }

                    if (result == null)
                    {
                        result = new SexpArrayInt(res);
                    }
                }
                break;

getting and setting raw data

i want to write variables from the rserve directly to a Database, using c# and RserveCLI2. As these variables can be complex (e.g. environments) the Sexp class disrupts them sometimes. As I do not want to get single entries, i wanted to receive the data as a SexpRaw and write the binary stream to the database. later on loading the data i wanted to do this the other way around and read the stream from the mysql server into SexpRaw, send this sexp to rserve and having the original variable back in the environment.
Unfortunately this did not work. Is there a hint how i could solve this?

thanx

List of NAs is returned as SexpArrayBool instead of SexpArrayDouble

I faced this issue today: I have an R algorithm that should return a list of doubles. Whenever it returns a list that does contain NAs only, it will be decoded as a SexpArrayBool and .AsDoubles will run into an NotSupportedException.

So, now I am doing this workaround:

public IList<double> GetDoublesVector(string symbolOrExpression)
    {
        try
        {
            return _rConnection.Eval(symbolOrExpression).AsDoubles.ToList();
        }
        catch (NotSupportedException e)
        {
            return ((ICollection<Sexp>) _rConnection.Eval(symbolOrExpression).Values).Select<Sexp, double>(s =>
            {
                if (s.IsNa)
                {
                    return Double.NaN;
                }
                else
                {
                    return s.AsDouble;
                }
            }).ToList();
        }
    }

Question: RserveCLI - Passing in R functions from C# to R

Hi Suraj,

I am trying to use your code it in an attempt to send functions to the R console within my virtual server. I can do simple and basic arithmetic as well call 1 or 2 of the built in functions i.e. getwd().

I want to try and create an R functions like "add2Nums <- function(x,y) {x+y}" from the c# side to run within R.

I was wondering if you have any kind of tutorial for a newbs like my self in how to go and use this RserveCLI code better

Thanks

Nullable doubles

There is an option to pass nullable booleans over the connection:

Sexp.Make(bool? x)

But there aren't options to pass on nullable strings, ints, doubles, ...

Why is that?
And more importandly, what would be the best solution to pass on nullable doubles?

Regards

Upgrade project to VS 2015 & target .NET 4.5

Following on from the comment as part of issue #30:

I think this project is ready for an upgrade and I say we keep it simple - lets just update to VS2015, .net 4.5 and if anyone complains we can address it at that point. As you mention, it's hard to tell how many users there are and it's open source so anyone can fork/branch/and compile to whatever they want. For now, I'd say lets not maintain a separate PCL library, lets just upgrade the whole thing to 4.5/VS2015.

  • Upgrade to VS 2015
  • Target .NET Framework 4.5

Did not receive Rserve ID signature.

I've got some code that establishes a connection to an RServe instance and generates some forecasts. Typically there are a few hundred forecasts that need to be generated though, so the code is a loop that fetches some data from a database, creates an RConnection, runs a forecast against the data using R, closes/Disposes of the RConnection, rinse and repeat.

The first 40 or so of these connections/forecasts runs without any problem. After that though, I systematically get an eror from line 379 of RConnection.cs, in the Init() method:
"Did not receive Rserve ID signature."

In fact, the entire buf is just zeros after the call to _socket.Receive( buf ).

Has anyone else run into this? If I restart the Rserve server I can then start anew, but once again, after 40 or so requests I'm no longer able to connect to Rserve via RserveCLI2 (or RserveCLI - so this is not a new problem). That kind of makes me think this might be more of a problem with the Rserve binary server than with the .NET client library... but that seemed so improbably that I figured I'd check here first.

TIA.

Cheers,
James

rterm: good choice?

rterm might be useful for running test, but it is definitively a no-go for any end-user application. User are frightened by an appearing black window with all that confusing text, and will close it immediately.

It should be possible to hide the window totally.

On the other side, why not use rscript which has been build for this sort of job?

Tranfer RserveCLI2 to a repo under an org

Should we create an org and transfer the RserveCLI2 repo into that org? Very little is lost in terms of ownership but much else is gained in terms of organisation, repos & stability.

Unit tests break on a 32-bit platform

All unit tests fail when run on a 32-bit platform at time of launching the server process:

RserveCLI2.Test.SexpArrayBoolTest.Various_ArrayBool : System.ComponentModel.Win32Exception : The specified executable is not a valid application for this OS platform.
Stack Trace:
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at RserveCLI2.Test.Rservice..ctor(Boolean showWindow, Int32 maxInputBufferSizeInKb) in C:\RserveCLI2\RserveCLI2.Test\Rservice.cs:line 70
   at RserveCLI2.Test.SexpArrayBoolTest.Various_ArrayBool() in C:\RserveCLI2\RserveCLI2.Test\SexpArrayBoolTest.cs:line 91

It seems to be that problem is hard-coding for x64 only.

Can I use all R libraries in Qlik Sense Desktop, and call them in the Load Script Editor ?

Hi everyone,
this is my script:
DEALOAD:
LOAD
DMU,
INPUT1,
INPUT2,
OUTPUT1,
OUTPUT2,
OUTPUT3,
OUTPUT4

FROM [lib://dati/deaDB.xlsx]
(ooxml, embedded labels, table is Sheet1);

SSELoad:
Load
INPUT1,
INPUT2,
OUTPUT1,
OUTPUT2,
OUTPUT3,
OUTPUT4,

R.ScriptEval('cbind(q$INPUT1, q$INPUT2);', INPUT1, INPUT2) as X,

R.ScriptEval('cbind(q$OUTPUT1, q$OUTPUT2, q$OUTPUT3, q$OUTPUT4);', OUTPUT1, OUTPUT2, OUTPUT3, OUTPUT4) as Y

Resident DEALOAD;

SSEload2:

LOAD
X,
Y,

R.ScriptEval('library(Benchmarking); dea(q$X, q$Y);', X, Y) AS DEA

Resident SSELoad;

At the end I have this error from SSEtoRserve:

Evaluating library(Benchmarking); dea(q$X, q$Y);
SSEtoRserve.RServeEvaluator|Param names: X Y
Cannot decode an Sexp because the type is not recognized: 48.

There is an error in the script or Qlik Sense can not read the R library Benchmarking ?

Dependabot couldn't find a <anything>.(cs|vb|fs)proj for this project

Dependabot couldn't find a .(cs|vb|fs)proj for this project.

Dependabot requires a .(cs|vb|fs)proj to evaluate your project's current Dotnet dependencies. It had expected to find one at the path: /<anything>.(cs|vb|fs)proj.

If this isn't a Dotnet project, or if it is a library, you may wish to disable updates for it from within Dependabot.

You can mention @dependabot in the comments below to contact the Dependabot team.

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.