RserveLink

An NDoc Documented Class Library

RserveLink Namespace

Namespace hierarchy

Classes

Class | Description
Rbool | Implementation of tri-state logical data type in R.The three states are True, False and Not available. To obtain truly boolean value, you'll need to use isTRUE or isFALSE since there is no canonical representation of RBool in boolean.
Rconnection | Class providing TCP/IP connection to an Rserve
RconnectionException | Represents errors that occur during Rserve connection
Rexp | Representation of R-eXpressions.
Rfactor | Representation of a factor variable. In R there is no actual xpression type called "factor", instead it is coded as an int vector with a list attribute. The parser code of REXP converts such constructs directly into the RFactor objects and defines an own XT_FACTOR type.
Rlist | Implementation of R-lists The point is that the parser tries to interpret lists to be of the form entry=value, where entry is stored in the "head" part, and value is stored in the "body" part. Then using At it is possible to fetch "body" for a specific "head". The terminology used is partly from hash fields - "keys" are the elements in "head" and values are in "body" Keys. On the other hand, R uses lists to store complex internal structures, which are not parsed according to the structure - in that case "head" and "body" have to be evaluated separately according to their meaning in that context.
UnixCrypt | Class supported Unix crypt method.

Enumerations

Enumeration | Description
DataTypes | Data types for the transport protocol (QAP1)
RBoolValues | Logical states for Rbool data type
RCommands | Availiable Rserve commands
Xpression | XpressionTypes


DataTypes Enumeration

Data types for the transport protocol (QAP1)

public enum DataTypes

Members

Member Name | Description
INT | int
CHAR | char
DOUBLE | double
STRING | 0 terminated string
BYTESTREAM | stream of bytes (unlike DT_STRING may contain 0)
SEXP | encoded SEXP
ARRAY | array of objects (i.e. first 4 bytes specify how many subsequent objects are part of the array; 0 is legitimate
LARGE | if this flag is set then the length of the object is coded as 56-Bit integer enlarging the header by 4 bytes

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

RserveLink Namespace


Rbool Class

Implementation of tri-state logical data type in R.The three states are True, False and Not available. To obtain truly boolean value, you'll need to use isTRUE or isFALSE since there is no canonical representation of RBool in boolean.

For a list of all members of this type, see Rbool Members.

System.Object
Rbool

public class Rbool

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

Rbool Members | RserveLink Namespace


Rbool Members

Rbool overview

Public Instance Constructors

Rbool Overloaded. Initializes a new instance of the Rbool class.

Public Instance Properties

Value Actual value 1 - true 0 - false 2 - na

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
isFALSE | Return true if Rbool value is "false" else return false.
isNA | Return true if Rbool value is "Not available" else return false.
isTRUE | Return true if Rbool value is "true" else return false.
ToString | Converts the Rbool value of this instance to string representation

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rbool Class | RserveLink Namespace


Rbool Constructor

Constructor of Rbool object

Overload List

Constructor of Rbool object

public Rbool(RBoolValues);

Constructor of Rbool object

public Rbool(Boolean);

See Also

Rbool Class | RserveLink Namespace


Rbool Constructor (RBoolValues)

Constructor of Rbool object

public Rbool(
RBoolValues input
);

Parameters

input

See Also

Rbool Class | RserveLink Namespace | Rbool Constructor Overload List


Rbool Constructor (Boolean)

Constructor of Rbool object

public Rbool(
Boolean input
);

Parameters

input
Boolean value

See Also

Rbool Class | RserveLink Namespace | Rbool Constructor Overload List


Rbool Properties

The properties of the Rbool class are listed below. For a complete list of Rbool class members, see the Rbool Members topic.

Public Instance Properties

Value Actual value 1 - true 0 - false 2 - na

See Also

Rbool Class | RserveLink Namespace


Value Property

An NDoc Documented Class Library

Rbool.Value Property

Actual value 1 - true 0 - false 2 - na

public Int32 Value {get;}

See Also

Rbool Class | RserveLink Namespace


Rbool Methods

The methods of the Rbool class are listed below. For a complete list of Rbool class members, see the Rbool Members topic.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
isFALSE | Return true if Rbool value is "false" else return false.
isNA | Return true if Rbool value is "Not available" else return false.
isTRUE | Return true if Rbool value is "true" else return false.
ToString | Converts the Rbool value of this instance to string representation

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rbool Class | RserveLink Namespace


Rbool.isFALSE Method

Return true if Rbool value is "false" else return false.

public bool isFALSE();

Return Value

See Also

Rbool Class | RserveLink Namespace


Rbool.isNA Method

Return true if Rbool value is "Not available" else return false.

public bool isNA();

Return Value

Boolean value

See Also

Rbool Class | RserveLink Namespace


Rbool.isTRUE Method

Return true if Rbool value is "true" else return false.

public bool isTRUE();

Return Value

Boolean value

See Also

Rbool Class | RserveLink Namespace


Rbool.ToString Method

Converts the Rbool value of this instance to string representation

public override string ToString();

Return Value

string representation

See Also

Rbool Class | RserveLink Namespace


RBoolValues Enumeration

Logical states for Rbool data type

public enum RBoolValues

Members

Member Name | Description
TRUE | True
FALSE | False
NA | Not available

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

RserveLink Namespace


RCommands Enumeration

Availiable Rserve commands

public enum RCommands

Members

Member Name | Description
login | Login to Rserve
voidEval | Evaluate without result sending
eval | Evaluate with result sending
shutdown | Shutdown Rserve
openFile | Open a file on the Rserve
createFile | Create a file on the Rserve
closeFile | Close a file on the Rserve
readFile | Read file from Rserve
writeFile | Write a file on the Rserve
removeFile | Remove a file from Rserve
setSEXP | Set value on the Rserve (SEXP type)
assignSEXP | Assign value on the Rserve (SEXP type)
setBufferSize | this commad allow clients to request bigger buffer sizes if large data is to be transported from Rserve to the client. (incoming buffer is resized automatically)

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

RserveLink Namespace


Rconnection Class

Class providing TCP/IP connection to an Rserve

For a list of all members of this type, see Rconnection Members.

System.Object
Rconnection

public class Rconnection : IDisposable

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Example

This example show to order files on the Rserve.

 using System;
 using System.Collections.Generic;
 using System.Text;
 using System.IO;
 using RserveLink;

 namespace rservelinktest
 {
    class Program
    {
        static void Main()
        {
            /* create connection with Rserve */
            Rconnection MyConnection = new Rconnection();
            MyConnection.Connect();

            /* create file, write text and close */
            MyConnection.CreateFile("example1.txt");
            MyConnection.WriteFile("This is example1 text");
            MyConnection.CloseFile();

            /* create file on our side */
            FileStream fs = File.Create("example2.txt");
            fs.Write(ASCIIEncoding.ASCII.GetBytes("This is example2 text"), 0, 21);
            fs.Close();

            /* open file and copy to the Rserve */
            fs = File.Open("example2.txt", FileMode.Open);
            MyConnection.CreateFile("example2.txt");
            MyConnection.PacketSize = 4;        //max packet length 16 (header) + 4 (data) bytes
            MyConnection.WriteFile((Stream)fs);
            MyConnection.CloseFile();
            fs.Close();

            /* read files from Rserve */
            String response;
            MyConnection.OpenFile("example1.txt");
            MyConnection.ReadFile(32, out response);
            MyConnection.CloseFile();
            Console.WriteLine("example1.txt: " + response);

            MyConnection.OpenFile("example2.txt");
            MyConnection.ReadFile(32, out response);
            MyConnection.CloseFile();
            Console.WriteLine("example2.txt: " + response);

            MyConnection.Disconnect();
        }
    }
 }

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

Rconnection Members | RserveLink Namespace


Rconnection Members

Rconnection overview

Public Instance Constructors

Rconnection Overloaded. Initializes a new instance of the Rconnection class.

Public Instance Properties

Host | Host IP address.
IsConnected | Connection state. Return true if this connection is alive.
NeedLogin | Check authentication requirement sent by server. Return true is server requires authentication. In such case first command after connecting must be login.
PacketSize | Max length (in bytes) of data which will be send to Rserve, when we use WriteFile(Stream) method. This is only data length, all packet consist of data and header (always 16 bytes).
Port | Port.
ReceivedBytesCount | Count of received Bytes.
RserveVersion | Rserve version
SendedBytesCount | Count of sended Bytes.

Public Instance Methods

Assign | Assign a content of a REXP to a symbol in R. The symbol is created if it doesn't exist already.
CloseFile | Close file on the Rserve
Connect | Make connection to the Rserve.
CreateFile | Create a file on the Rserve for writing
Disconnect | Didconnect with Rserve.
Dispose |
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Eval | Evaluates the given command and retrieves the result
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
login |
OpenFile | Open a file on the Rserve for reading
ReadFile | Overloaded. Reads specified number of bytes (or less) from the remote file.
RemoveFile | Remove a file on the Rserve
ToString (inherited from Object) | Returns a String that represents the current Object.
VoidEval | Evaluates the given command without retriving the result
WriteFile | Overloaded. Method write string value to the remote file

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rconnection Class | RserveLink Namespace


Rconnection Constructor

Make a new Rconnection object with specified host and port.

Overload List

Make a new Rconnection object with default port and localhost.

public Rconnection();

Make a new Rconnection object with specified host and port.

public Rconnection(String,Int32);

See Also

Rconnection Class | RserveLink Namespace


Rconnection Constructor (String, Int32)

Make a new Rconnection object with specified host and port.

public Rconnection(
String Host,
Int32 Port
);

Parameters

Host
host Name/IP
Port
TCP port

See Also

Rconnection Class | RserveLink Namespace | Rconnection Constructor Overload List


Rconnection Constructor ()

Make a new Rconnection object with default port and localhost.

public Rconnection();

See Also

Rconnection Class | RserveLink Namespace | Rconnection Constructor Overload List


Rconnection Properties

The properties of the Rconnection class are listed below. For a complete list of Rconnection class members, see the Rconnection Members topic.

Public Instance Properties

Host | Host IP address.
IsConnected | Connection state. Return true if this connection is alive.
NeedLogin | Check authentication requirement sent by server. Return true is server requires authentication. In such case first command after connecting must be login.
PacketSize | Max length (in bytes) of data which will be send to Rserve, when we use WriteFile(Stream) method. This is only data length, all packet consist of data and header (always 16 bytes).
Port | Port.
ReceivedBytesCount | Count of received Bytes.
RserveVersion | Rserve version
SendedBytesCount | Count of sended Bytes.

See Also

Rconnection Class | RserveLink Namespace


Host Property

An NDoc Documented Class Library

Rconnection.Host Property

Host IP address.

public String Host {get; set;}

See Also

Rconnection Class | RserveLink Namespace


IsConnected Property

An NDoc Documented Class Library

Rconnection.IsConnected Property

Connection state. Return true if this connection is alive.

public Boolean IsConnected {get;}

See Also

Rconnection Class | RserveLink Namespace


NeedLogin Property

An NDoc Documented Class Library

Rconnection.NeedLogin Property

Check authentication requirement sent by server. Return true is server requires authentication. In such case first command after connecting must be login.

public Boolean NeedLogin {get;}

See Also

Rconnection Class | RserveLink Namespace


PacketSize Property

An NDoc Documented Class Library

Rconnection.PacketSize Property

Max length (in bytes) of data which will be send to Rserve, when we use WriteFile(Stream) method. This is only data length, all packet consist of data and header (always 16 bytes).

public Int32 PacketSize {get; set;}

See Also

Rconnection Class | RserveLink Namespace


Port Property

An NDoc Documented Class Library

Rconnection.Port Property

Port.

public Int32 Port {get; set;}

See Also

Rconnection Class | RserveLink Namespace


ReceivedBytesCount Property

An NDoc Documented Class Library

Rconnection.ReceivedBytesCount Property

Count of received Bytes.

public Int32 ReceivedBytesCount {get;}

See Also

Rconnection Class | RserveLink Namespace


RserveVersion Property

An NDoc Documented Class Library

Rconnection.RserveVersion Property

Rserve version

public Int32 RserveVersion {get;}

See Also

Rconnection Class | RserveLink Namespace


SendedBytesCount Property

An NDoc Documented Class Library

Rconnection.SendedBytesCount Property

Count of sended Bytes.

public Int32 SendedBytesCount {get;}

See Also

Rconnection Class | RserveLink Namespace


Rconnection Methods

The methods of the Rconnection class are listed below. For a complete list of Rconnection class members, see the Rconnection Members topic.

Public Instance Methods

Assign | Assign a content of a REXP to a symbol in R. The symbol is created if it doesn't exist already.
CloseFile | Close file on the Rserve
Connect | Make connection to the Rserve.
CreateFile | Create a file on the Rserve for writing
Disconnect | Didconnect with Rserve.
Dispose |
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Eval | Evaluates the given command and retrieves the result
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
login |
OpenFile | Open a file on the Rserve for reading
ReadFile | Overloaded. Reads specified number of bytes (or less) from the remote file.
RemoveFile | Remove a file on the Rserve
ToString (inherited from Object) | Returns a String that represents the current Object.
VoidEval | Evaluates the given command without retriving the result
WriteFile | Overloaded. Method write string value to the remote file

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rconnection Class | RserveLink Namespace


Rconnection.Assign Method

Assign a content of a REXP to a symbol in R. The symbol is created if it doesn't exist already.

public void Assign(
String symbol,
Rexp input
);

Parameters

symbol
Symbol name.It is the responsibility of the user to make sure that the symbol name is valid in R. In fact R will always create the symbol, but it may not be accessible (examples: "bar\nfoo" or "bar$foo").
input
Contents

See Also

Rconnection Class | RserveLink Namespace


Rconnection.CloseFile Method

Close file on the Rserve

public void CloseFile();

See Also

Rconnection Class | RserveLink Namespace


Rconnection.Connect Method

Make connection to the Rserve.

public void Connect();

See Also

Rconnection Class | RserveLink Namespace


Rconnection.CreateFile Method

Create a file on the Rserve for writing

public void CreateFile(
String FileName
);

Parameters

FileName
File name should not contain any path delimiters, since Rserve may restrict the access to local working directory.

See Also

Rconnection Class | RserveLink Namespace


Rconnection.Disconnect Method

Didconnect with Rserve.

public void Disconnect();

See Also

Rconnection Class | RserveLink Namespace


Rconnection.Dispose Method

public void Dispose();

Implements

IDisposable.

See Also

Rconnection Class | RserveLink Namespace


Rconnection.Eval Method

Evaluates the given command and retrieves the result

public Rexp Eval(
String Cmd
);

Parameters

Cmd
command

Return Value

R-xpression

See Also

Rconnection Class | RserveLink Namespace


Rconnection.login Method

public void login(
String user,
String pwd
);

See Also

Rconnection Class | RserveLink Namespace


Rconnection.OpenFile Method

Open a file on the Rserve for reading

public void OpenFile(
String FileName
);

Parameters

FileName
File name should not contain any path delimiters, since Rserve may restrict the access to local working directory.

See Also

Rconnection Class | RserveLink Namespace


ReadFile Method

An NDoc Documented Class Library

Rconnection.ReadFile Method

Reads specified number of bytes (or less) from the remote file.

Overload List

Reads specified number of bytes (or less) from the remote file.

public void ReadFile(Int32,out Byte[]&);

Reads specified number of bytes (or less) from the remote file.

public void ReadFile(Int32,out String&);

See Also

Rconnection Class | RserveLink Namespace


Rconnection.ReadFile Method (Int32, Byte[]&)

Reads specified number of bytes (or less) from the remote file.

public void ReadFile(
Int32 size,
out Byte[]& data
);

Parameters

size
maximal number of bytes to read
data
buffer to store the read bytes

See Also

Rconnection Class | RserveLink Namespace | Rconnection.ReadFile Overload List


Rconnection.ReadFile Method (Int32, String&)

Reads specified number of bytes (or less) from the remote file.

public void ReadFile(
Int32 size,
out String& Value
);

Parameters

size
maximal number of bytes to read
Value
String value to store the read and ASCII decoded bytes

See Also

Rconnection Class | RserveLink Namespace | Rconnection.ReadFile Overload List


Rconnection.RemoveFile Method

Remove a file on the Rserve

public void RemoveFile(
String FileName
);

Parameters

FileName
File name should not contain any path delimiters, since Rserve may restrict the access to local working directory.

See Also

Rconnection Class | RserveLink Namespace


Rconnection.VoidEval Method

Evaluates the given command without retriving the result

public void VoidEval(
String Cmd
);

Parameters

Cmd
command

See Also

Rconnection Class | RserveLink Namespace


WriteFile Method

An NDoc Documented Class Library

Rconnection.WriteFile Method

Method write string value to the remote file

Overload List

Method write string value to the remote file

public void WriteFile(Stream);

Method write string value to the remote file

public void WriteFile(String);

See Also

Rconnection Class | RserveLink Namespace


Rconnection.WriteFile Method (Stream)

Method write string value to the remote file

public void WriteFile(
Stream input
);

Parameters

input
value to send

See Also

Rconnection Class | RserveLink Namespace | Rconnection.WriteFile Overload List


Rconnection.WriteFile Method (String)

Method write string value to the remote file

public void WriteFile(
String input
);

Parameters

input
value to send

See Also

Rconnection Class | RserveLink Namespace | Rconnection.WriteFile Overload List


RconnectionException Class

Represents errors that occur during Rserve connection

For a list of all members of this type, see RconnectionException Members.

System.Object
Exception
RconnectionException

public class RconnectionException : Exception

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

RconnectionException Members | RserveLink Namespace


RconnectionException Members

RconnectionException overview

Public Instance Constructors

RconnectionException Overloaded. Initializes a new instance of the RconnectionException class.

Public Instance Properties

Data (inherited from Exception) | Gets a collection of key/value pairs that provide additional, user-defined information about the exception.
ErrorCode | Gets a error code.
HelpLink (inherited from Exception) | Gets or sets a link to the help file associated with this exception.
InnerException (inherited from Exception) | Gets the Exception instance that caused the current exception.
Message | Gets a message that describes the current exception.
Source (inherited from Exception) | Gets or sets the name of the application or the object that causes the error.
StackTrace (inherited from Exception) | Gets a string representation of the frames on the call stack at the time the current exception was thrown.
TargetSite (inherited from Exception) | Gets the method that throws the current exception.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBaseException (inherited from Exception) | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetObjectData (inherited from Exception) | When overridden in a derived class, sets the SerializationInfo with information about the exception.
GetType (inherited from Exception) | Gets the runtime type of the current instance.
ToString (inherited from Exception) | Creates and returns a string representation of the current exception.

Protected Instance Properties

HResult (inherited from Exception) Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

RconnectionException Class | RserveLink Namespace


RconnectionException Constructor

Constructor.

Overload List

Constructor.

public RconnectionException(Int32);

Constructor.

public RconnectionException(String);

See Also

RconnectionException Class | RserveLink Namespace


RconnectionException Constructor (String)

Constructor.

public RconnectionException(
String Message
);

Parameters

Message
Message about error

See Also

RconnectionException Class | RserveLink Namespace | RconnectionException Constructor Overload List


RconnectionException Constructor (Int32)

Constructor.

public RconnectionException(
Int32 ErrorCode
);

Parameters

ErrorCode
Error code

See Also

RconnectionException Class | RserveLink Namespace | RconnectionException Constructor Overload List


RconnectionException Properties

The properties of the RconnectionException class are listed below. For a complete list of RconnectionException class members, see the RconnectionException Members topic.

Public Instance Properties

Data (inherited from Exception) | Gets a collection of key/value pairs that provide additional, user-defined information about the exception.
ErrorCode | Gets a error code.
HelpLink (inherited from Exception) | Gets or sets a link to the help file associated with this exception.
InnerException (inherited from Exception) | Gets the Exception instance that caused the current exception.
Message | Gets a message that describes the current exception.
Source (inherited from Exception) | Gets or sets the name of the application or the object that causes the error.
StackTrace (inherited from Exception) | Gets a string representation of the frames on the call stack at the time the current exception was thrown.
TargetSite (inherited from Exception) | Gets the method that throws the current exception.

Protected Instance Properties

HResult (inherited from Exception) Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

See Also

RconnectionException Class | RserveLink Namespace


ErrorCode Property

An NDoc Documented Class Library

RconnectionException.ErrorCode Property

Gets a error code.

public Int32 ErrorCode {get;}

See Also

RconnectionException Class | RserveLink Namespace


Message Property

An NDoc Documented Class Library

RconnectionException.Message Property

Gets a message that describes the current exception.

public override String Message {get;}

See Also

RconnectionException Class | RserveLink Namespace


Rexp Class

Representation of R-eXpressions.

For a list of all members of this type, see Rexp Members.

System.Object
Rexp

public class Rexp

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Example

using System;
using System.Text;
using RserveLink;

namespace Rexample
{
   class Program
   {
       static void Main(string[] args)
       {
            Double[] values = new Double[10];
            for (int i = 0; i < values.Length; i++)
            {
                values[i] = i;
            }
            try
            {
                /* make connection to Rserve */
                Rconnection rc = new Rconnection();
                rc.Connect();

                /* copy values to Rserve */
                Rexp rdata = new Rexp(values);
                rc.Assign("val", rdata);

                /* compute mean of values */
                Rexp response = rc.Eval("mean(val)");
                Double mean = response.AsDouble();
                rc.Disconnect();

                /* show result */
                Console.WriteLine("Values: ");
                foreach (Double current in values)
                {
                    Console.Write(current.ToString() + " ");
                }
                Console.WriteLine("\nMean: " + mean.ToString());
            }
            catch (RserveLink.RconnectionException myException)
            {
                Console.WriteLine(myException.Message);
            }
       }
   }
}

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

Rexp Members | RserveLink Namespace


Rexp Members

Rexp overview

Public Static Methods

parseREXP Representation of R-eXpressions.

Public Instance Constructors

Rexp Overloaded. Initializes a new instance of the Rexp class.

Public Instance Properties

Attrib Attribute xpression or
null
if none
Data | Content of the xpression
Xtype | Xpression type

Public Instance Methods

AsBool | Get content of the Rexp as Rbool
AsDouble | Get content of the Rexp as Double
AsDoubleArray | Get content of the Rexp as an array of doubles. Array of integers, single double and single integer are automatically converted into such an array if necessary.
AsDoubleMatrix | Returns the content of the Rexp as a matrix of doubles (2D-array: m[rows][cols]).
AsFactor | Get content of the Rexp as Rfactor
AsInt32 | Get content of the Rexp as Int32
AsIntArray | Get content of the Rexp as an array of integers
AsList | Get content of the Rexp as Rlist
AsMatrix | This is alias for AsDoubleMatrix
AsString | Get content of the Rexp as string
AsVector | Get content of the Rexp as List of Rexp
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString | Converts the Rexp value of this instance to string representation

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rexp Class | RserveLink Namespace


Rexp Constructor

Constructor of Rexp object which we can send to Rserve

Overload List

Constructor of Rexp object which we can send to Rserve

public Rexp(Double);

Constructor of Rexp object which we can send to Rserve

public Rexp(Double[]);

Constructor of Rexp object which we can send to Rserve

public Rexp(Int32);

Constructor of Rexp object which we can send to Rserve

public Rexp(Int32[]);

Constructor of Rexp object which we can send to Rserve

public Rexp(String[]);

See Also

Rexp Class | RserveLink Namespace


Rexp Constructor (Double)

Constructor of Rexp object which we can send to Rserve

public Rexp(
Double input
);

Parameters

input
Double value

See Also

Rexp Class | RserveLink Namespace | Rexp Constructor Overload List


Rexp Constructor (Int32)

Constructor of Rexp object which we can send to Rserve

public Rexp(
Int32 input
);

Parameters

input
Int32 value

See Also

Rexp Class | RserveLink Namespace | Rexp Constructor Overload List


Rexp Constructor (Double[])

Constructor of Rexp object which we can send to Rserve

public Rexp(
Double[] input
);

Parameters

input
Array of Doubles values

See Also

Rexp Class | RserveLink Namespace | Rexp Constructor Overload List


Rexp Constructor (Int32[])

Constructor of Rexp object which we can send to Rserve

public Rexp(
Int32[] input
);

Parameters

input
Array of Int32 values

See Also

Rexp Class | RserveLink Namespace | Rexp Constructor Overload List


Rexp Constructor (String[])

Constructor of Rexp object which we can send to Rserve

public Rexp(
String[] input
);

Parameters

input
Array of String values

See Also

Rexp Class | RserveLink Namespace | Rexp Constructor Overload List


Rexp Properties

The properties of the Rexp class are listed below. For a complete list of Rexp class members, see the Rexp Members topic.

Public Instance Properties

Attrib Attribute xpression or
null
if none
Data | Content of the xpression
Xtype | Xpression type

See Also

Rexp Class | RserveLink Namespace


Attrib Property

An NDoc Documented Class Library

Rexp.Attrib Property

Attribute xpression or

null
if none

public Rexp Attrib {get; set;}

See Also

Rexp Class | RserveLink Namespace


Data Property

An NDoc Documented Class Library

Rexp.Data Property

Content of the xpression

public Object Data {get; set;}

See Also

Rexp Class | RserveLink Namespace


Xtype Property

An NDoc Documented Class Library

Rexp.Xtype Property

Xpression type

public Xpression Xtype {get; set;}

See Also

Rexp Class | RserveLink Namespace


Rexp Methods

The methods of the Rexp class are listed below. For a complete list of Rexp class members, see the Rexp Members topic.

Public Static Methods

parseREXP Representation of R-eXpressions.

Public Instance Methods

AsBool | Get content of the Rexp as Rbool
AsDouble | Get content of the Rexp as Double
AsDoubleArray | Get content of the Rexp as an array of doubles. Array of integers, single double and single integer are automatically converted into such an array if necessary.
AsDoubleMatrix | Returns the content of the Rexp as a matrix of doubles (2D-array: m[rows][cols]).
AsFactor | Get content of the Rexp as Rfactor
AsInt32 | Get content of the Rexp as Int32
AsIntArray | Get content of the Rexp as an array of integers
AsList | Get content of the Rexp as Rlist
AsMatrix | This is alias for AsDoubleMatrix
AsString | Get content of the Rexp as string
AsVector | Get content of the Rexp as List of Rexp
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString | Converts the Rexp value of this instance to string representation

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rexp Class | RserveLink Namespace


Rexp.AsBool Method

Get content of the Rexp as Rbool

public Rbool AsBool();

Return Value

Rbool content or

null
if the Rexp is no logical value

See Also

Rexp Class | RserveLink Namespace


Rexp.AsDouble Method

Get content of the Rexp as Double

public double AsDouble();

Return Value

Double content or 0.0 if the Rexp is no Double

See Also

Rexp Class | RserveLink Namespace


Rexp.AsDoubleArray Method

Get content of the Rexp as an array of doubles. Array of integers, single double and single integer are automatically converted into such an array if necessary.

public double[] AsDoubleArray();

Return Value

Double[] content or

null
if the Rexp is not a array of doubles or integers

See Also

Rexp Class | RserveLink Namespace


Rexp.AsDoubleMatrix Method

Returns the content of the Rexp as a matrix of doubles (2D-array: m[rows][cols]).

public double[,] AsDoubleMatrix();

Return Value

2D array of doubles in the form double[rows][cols] or

null
if the contents is no 2-dimensional matrix of doubles

Example

Double[,] m=RconnectionObject.Eval("matrix(c(1,2,3,4,5,6),2,3)").AsDoubleMatrix();

See Also

Rexp Class | RserveLink Namespace


Rexp.AsFactor Method

Get content of the Rexp as Rfactor

public Rfactor AsFactor();

Return Value

Rfactor content or

null
if the Rexp is no factor

See Also

Rexp Class | RserveLink Namespace


Rexp.AsInt32 Method

Get content of the Rexp as Int32

public int AsInt32();

Return Value

Int32 content or 0 if the Rexp is no integer

See Also

Rexp Class | RserveLink Namespace


Rexp.AsIntArray Method

Get content of the Rexp as an array of integers

public int[] AsIntArray();

Return Value

Int32[] content or

null
if the Rexp is not a array of integers

See Also

Rexp Class | RserveLink Namespace


Rexp.AsList Method

Get content of the Rexp as Rlist

public Rlist AsList();

Return Value

Rlist content or

null
if the Rexp is no list

See Also

Rexp Class | RserveLink Namespace


Rexp.AsMatrix Method

This is alias for AsDoubleMatrix

public double[,] AsMatrix();

Return Value

See Also

Rexp Class | RserveLink Namespace


Rexp.AsString Method

Get content of the Rexp as string

public string AsString();

Return Value

string content or

null
if the Rexp is no string

See Also

Rexp Class | RserveLink Namespace


Rexp.AsVector Method

Get content of the Rexp as List of Rexp

public List<T> AsVector();

Return Value

Vector content or

null
if the Rexp is no Vector

See Also

Rexp Class | RserveLink Namespace


Rexp.parseREXP Method

Representation of R-eXpressions.

public static int parseREXP(
out Rexp& x,
ref Byte[]& buffer,
Int32 offset
);

See Also

Rexp Class | RserveLink Namespace


Rexp.ToString Method

Converts the Rexp value of this instance to string representation

public override string ToString();

Return Value

string representation

See Also

Rexp Class | RserveLink Namespace


Rfactor Class

Representation of a factor variable. In R there is no actual xpression type called "factor", instead it is coded as an int vector with a list attribute. The parser code of REXP converts such constructs directly into the RFactor objects and defines an own XT_FACTOR type.

For a list of all members of this type, see Rfactor Members.

System.Object
Rfactor

public class Rfactor

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

Rfactor Members | RserveLink Namespace


Rfactor Members

Rfactor overview

Public Instance Constructors

Rfactor Overloaded. Initializes a new instance of the Rfactor class.

Public Instance Properties

Count The number of caes.

Public Instance Methods

Add | Add a new element (by name)
At | Returns name for a specific ID
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString | Converts the Rfactor value of this instance to string representation

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rfactor Class | RserveLink Namespace


Rfactor Constructor

Create a new, empty factor variable

Overload List

Create a new, empty factor variable

public Rfactor();

Special constructor used by Rexp parser to save some re-indexing and performing automatic index conversion

public Rfactor(Int32[],List<T>);

Create a new factor variable, base on the supplied arrays

public Rfactor(Int32[],String[]);

See Also

Rfactor Class | RserveLink Namespace


Rfactor Constructor ()

Create a new, empty factor variable

public Rfactor();

See Also

Rfactor Class | RserveLink Namespace | Rfactor Constructor Overload List


Rfactor Constructor (Int32[], String[])

Create a new factor variable, base on the supplied arrays

public Rfactor(
Int32[] i,
String[] v
);

Parameters

i
array if IDs (0 ... v.length-1)
v
values - category names

See Also

Rfactor Class | RserveLink Namespace | Rfactor Constructor Overload List


Rfactor Constructor (Int32[], List<T>)

Special constructor used by Rexp parser to save some re-indexing and performing automatic index conversion

public Rfactor(
Int32[] i,
List<T> v
);

Parameters

i
index array
v
vector of xpressions which should be all strings

See Also

Rfactor Class | RserveLink Namespace | Rfactor Constructor Overload List


Rfactor Properties

The properties of the Rfactor class are listed below. For a complete list of Rfactor class members, see the Rfactor Members topic.

Public Instance Properties

Count The number of caes.

See Also

Rfactor Class | RserveLink Namespace


Count Property

An NDoc Documented Class Library

Rfactor.Count Property

The number of caes.

public Int32 Count {get;}

See Also

Rfactor Class | RserveLink Namespace


Rfactor Methods

The methods of the Rfactor class are listed below. For a complete list of Rfactor class members, see the Rfactor Members topic.

Public Instance Methods

Add | Add a new element (by name)
At | Returns name for a specific ID
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString | Converts the Rfactor value of this instance to string representation

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rfactor Class | RserveLink Namespace


Rfactor.Add Method

Add a new element (by name)

public void Add(
String v
);

Parameters

v
value

See Also

Rfactor Class | RserveLink Namespace


Rfactor.At Method

Returns name for a specific ID

public string At(
Int32 i
);

Parameters

i
ID

Return Value

Name

See Also

Rfactor Class | RserveLink Namespace


Rfactor.ToString Method

Converts the Rfactor value of this instance to string representation

public override string ToString();

Return Value

string representation

See Also

Rfactor Class | RserveLink Namespace


Rlist Class

Implementation of R-lists
The point is that the parser tries to interpret lists to be of the form entry=value, where entry is stored in the "head" part, and value is stored in the "body" part. Then using At it is possible to fetch "body" for a specific "head". The terminology used is partly from hash fields - "keys" are the elements in "head" and values are in "body" Keys. On the other hand, R uses lists to store complex internal structures, which are not parsed according to the structure - in that case "head" and "body" have to be evaluated separately according to their meaning in that context.

For a list of all members of this type, see Rlist Members.

System.Object
Rlist

public class Rlist

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

Rlist Members | RserveLink Namespace


Rlist Members

Rlist overview

Public Instance Constructors

Rlist Overloaded. Initializes a new instance of the Rlist class.

Public Instance Properties

Body | Body xpression (CDR)
Head | Head xpression (CAR)
Tag | Tag xpression

Public Instance Methods

At | Overloaded. Get element at the specified position
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Keys | Returns all keys of the list
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rlist Class | RserveLink Namespace


Rlist Constructor

Contructs an empty list

Overload List

Contructs an empty list

public Rlist();

Constructs an initialized list

public Rlist(Rexp,Rexp);

See Also

Rlist Class | RserveLink Namespace


Rlist Constructor ()

Contructs an empty list

public Rlist();

See Also

Rlist Class | RserveLink Namespace | Rlist Constructor Overload List


Rlist Constructor (Rexp, Rexp)

Constructs an initialized list

public Rlist(
Rexp Head,
Rexp Body
);

Parameters

Head
Head xpression
Body
Body xpression

See Also

Rlist Class | RserveLink Namespace | Rlist Constructor Overload List


Rlist Properties

The properties of the Rlist class are listed below. For a complete list of Rlist class members, see the Rlist Members topic.

Public Instance Properties

Body | Body xpression (CDR)
Head | Head xpression (CAR)
Tag | Tag xpression

See Also

Rlist Class | RserveLink Namespace


Body Property

An NDoc Documented Class Library

Rlist.Body Property

Body xpression (CDR)

public Rexp Body {get; set;}

See Also

Rlist Class | RserveLink Namespace


Head Property

An NDoc Documented Class Library

Rlist.Head Property

Head xpression (CAR)

public Rexp Head {get; set;}

See Also

Rlist Class | RserveLink Namespace


Tag Property

An NDoc Documented Class Library

Rlist.Tag Property

Tag xpression

public Rexp Tag {get; set;}

See Also

Rlist Class | RserveLink Namespace


Rlist Methods

The methods of the Rlist class are listed below. For a complete list of Rlist class members, see the Rlist Members topic.

Public Instance Methods

At | Overloaded. Get element at the specified position
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Keys | Returns all keys of the list
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

Rlist Class | RserveLink Namespace


At Method

An NDoc Documented Class Library

Rlist.At Method

Get element at the specified position

Overload List

Get element at the specified position

public Rexp At(Int32);

Get xpression given a key

public Rexp At(String);

See Also

Rlist Class | RserveLink Namespace


Rlist.At Method (Int32)

Get element at the specified position

public Rexp At(
Int32 i
);

Parameters

i
index

Return Value

xpression at the index or null if list is not standartized or index out of bounds

See Also

Rlist Class | RserveLink Namespace | Rlist.At Overload List


Rlist.At Method (String)

Get xpression given a key

public Rexp At(
String v
);

Parameters

v
key

Return Value

xpression which corresponds to the given key or null if list is not standartized or key not found

See Also

Rlist Class | RserveLink Namespace | Rlist.At Overload List


Rlist.Keys Method

Returns all keys of the list

public string[] Keys();

Return Value

array containing all keys or null if list is not standartized

See Also

Rlist Class | RserveLink Namespace


UnixCrypt Class

Class supported Unix crypt method.

For a list of all members of this type, see UnixCrypt Members.

System.Object
UnixCrypt

public class UnixCrypt

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

UnixCrypt Members | RserveLink Namespace


UnixCrypt Members

UnixCrypt overview

Public Static Methods

crypt

Public Instance Constructors

UnixCrypt Constructor Initializes a new instance of the UnixCrypt class.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

UnixCrypt Class | RserveLink Namespace


UnixCrypt Constructor

Initializes a new instance of the UnixCrypt class.

public UnixCrypt();

See Also

UnixCrypt Class | RserveLink Namespace


UnixCrypt Methods

The methods of the UnixCrypt class are listed below. For a complete list of UnixCrypt class members, see the UnixCrypt Members topic.

Public Static Methods

crypt

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

UnixCrypt Class | RserveLink Namespace


UnixCrypt.crypt Method

public static string crypt(
String strpw,
String strsalt
);

See Also

UnixCrypt Class | RserveLink Namespace


Xpression Enumeration

XpressionTypes

public enum Xpression

Members

Member Name | Description
XT_NULL | xpression type: NULL
XT_INT | xpression type: integer
XT_DOUBLE | xpression type: double
XT_STR | xpression type: String
XT_LANG | xpression type: language construct (currently content is same as list)
XT_SYM | xpression type: symbol (content is symbol name: String)
XT_BOOL | xpression type: RBool
XT_VECTOR | xpression type: Vector
XT_LIST | xpression type: RList
XT_CLOS | xpression type: closure
XT_ARRAY_INT | xpression type: int[]
XT_ARRAY_DOUBLE | xpression type: double[]
XT_ARRAY_STR | xpression type: String[] (currently not used, Vector is used instead)
XT_ARRAY_BOOL_UA | internal use only! this constant should never appear in a REXP
XT_ARRAY_BOOL | xpression type: RBool[]
XT_UNKNOWN | xpression type: unknown; no assumptions can be made about the content
XT_FACTOR | xpression type: RFactor; this XT is internally generated (ergo is does not come from Rsrv.h) to support RFactor class which is built from XT_ARRAY_INT
XT_LARGE | new in 0102: if this flag is set then the length of the object is coded as 56-bit integer enlarging the header by 4 bytes
XT_HAS_ATTR | flag; if set, the following REXP is the attribute

Requirements

Namespace: RserveLink

Assembly: RserveLink (in RserveLink.dll)

See Also

RserveLink Namespace


Hierarchy

System.Object
RserveLink.Rbool
RserveLink.Rconnection ---- System.IDisposable
RserveLink.Rexp
RserveLink.Rfactor
RserveLink.Rlist
RserveLink.UnixCrypt
System.Exception ---- System.Runtime.Serialization.ISerializable
RserveLink.RconnectionException
System.ValueType
System.Enum ---- System.IComparable, System.IConvertible, System.IFormattable
RserveLink.DataTypes
RserveLink.RBoolValues
RserveLink.RCommands
RserveLink.Xpression

See Also

RserveLink Namespace