Programmer Guide/Shell Items/DCOM/SET DCOM: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
m (Text replace - "S_TOOLS-STx" to "{{STX}}")
Line 41: Line 41:
;<var>variable</var>
;<var>variable</var>


:The S_TOOLS-STx variable name, which contains the value to be assigned to <var>R_var_name</var> (the option /Variable can be used, but is optional).
:The {{STX}} variable name, which contains the value to be assigned to <var>R_var_name</var> (the option /Variable can be used, but is optional).


;<var>table</var>
;<var>table</var>


:The name of an S_TOOLS-STx table containing the values to be assigned to <var>R_var_name</var>. Note that by default only the column <code>0</code> is sent.
:The name of an {{STX}} table containing the values to be assigned to <var>R_var_name</var>. Note that by default only the column <code>0</code> is sent.


;<var>index</var>
;<var>index</var>
Line 110: Line 110:
;<var>variable</var>
;<var>variable</var>


:The name of an S_TOOLS-STx variable that will be assigned the value of <var>R_var_name</var>. The variable can receive string or number data.
:The name of an {{STX}} variable that will be assigned the value of <var>R_var_name</var>. The variable can receive string or number data.


;<var>table</var>
;<var>table</var>


:The name of an S_TOOLS-STx table to receive values from <var>R_var_name</var>. Note that a table can only receive vector or matrix data.
:The name of an {{STX}} table to receive values from <var>R_var_name</var>. Note that a table can only receive vector or matrix data.


;<var>index</var>
;<var>index</var>
Line 126: Line 126:
;<var>value</var>
;<var>value</var>


:The name of an S_TOOLS-STx value item that will be assigned the value of <var>R_var_name</var>. The value item can receive string, number, vector or matrix data.
:The name of an {{STX}} value item that will be assigned the value of <var>R_var_name</var>. The value item can receive string, number, vector or matrix data.


====R====
====R====
Line 132: Line 132:
R is a language and environment for statistical computing and graphics. You can find more details on their homepage: http://www.r-project.org/
R is a language and environment for statistical computing and graphics. You can find more details on their homepage: http://www.r-project.org/


S_TOOLS-STx can communicate with R using the DCOM interface implemented in S_TOOLS-STx as a shell item ([[Programmer Guide/Shell Items/DCOM/DCOM|DCOM]]).
{{STX}} can communicate with R using the DCOM interface implemented in {{STX}} as a shell item ([[Programmer Guide/Shell Items/DCOM/DCOM|DCOM]]).


Note that if you are running R 2.2 or greater, you will need the 2.0 R (D)COM server.
Note that if you are running R 2.2 or greater, you will need the 2.0 R (D)COM server.

Revision as of 17:59, 5 April 2011

SET DCOM

The following SET commands are understood by the DCOM shell item:

INVOKEMETHOD

SET $#dcomItem INVOKEMETHOD MethodName [param_1 param_2 .... param_n]

Invoke a DCOM object method.

MethodName the name of the remote method
param_1 ... param_n parameters for the method MethodName


SETDATA

The following commands are specific to the R statistical program.SET $#dcomItem SETDATA R_var_name string /Constant

SET $#dcomItem SETDATA R_var_name variable [/Variable]

SET $#dcomItem SETDATA R_var_name table [index count][/Variable]

Create a variable and set its value and type, in an R workspace. SETDATA is a special method implemented for use with the R DCOM server. Currently the following types of variables are supported: string, number(float) and matrix. The maximum number of dimensions for a matrix is currently two.

R_var_name

The name of the variable to be created in the R workspace.
string
In conjunction with the option /Constant the string to assign to the variable R_var_name. If string is a numerical expression, the numerical value is assigned.
variable
The STx variable name, which contains the value to be assigned to R_var_name (the option /Variable can be used, but is optional).
table
The name of an STx table containing the values to be assigned to R_var_name. Note that by default only the column 0 is sent.
index
If a table is passed, the index of the first field to use in the table. The default is 0.
count
If a table is passed, the number of fields to read (starting from index). Note that all fields from index to count-1 must be numerical fields. The default is 1.

Example

///////////////////////////////////////////////////////////////////////////////
//
//  Macro:          DCOMSetData
//  Description:    Send a string to the statistical package R and tell R to
//                  edit the string (i.e. open a text file).
//  Usage:          DCOMSetData
//  Return:         0
//  Author:         Jonnie White
//  History:        2005-04-26
//                  
///////////////////////////////////////////////////////////////////////////////
[macro dcomsetdata]

    #dcom := $(new DCOM * 'StatConnectorSrv.StatConnector')
    if '$#dcom' == '*' em -1 ; Error creating R DCOM server

    $#dcom INVOKEMETHOD Init R
    if '$rc' > 0 em  $rc ; Failed to invoke Init R method

    #myStr := 'The quick brown fox jumps over the lazy dog'

    $#dcom SETDATA myStr #myStr
    if '$rc' > 0 em $rc ; failed to setdata the R variable 'myStr'

    $#dcom INVOKEMETHOD EvaluateNoReturn ' edit(myStr)'
    if '$rc' > 0 em $rc ; failed to evaluate 'edit(myStr)'

    $#DCOM SETDATA myStr '$#myStr' /Constant
    if '$rc' > 0 em $rc ; failed to setdata myStr #myStr

    $#dcom INVOKEMETHOD EvaluateNoReturn 'edit(myStr)'
    if '$rc' > 0 em $rc ; failed to evaluate 'edit(myStr)'

    delete $#dcom
exit 1 int 0

GETDATA

The following commands are specific to the R statistical program.SET $#dcomItem GETDATA R_var_name variable

SET $#dcomItem GETDATA R_var_name table [index{0} count{1}]

SET $#dcomItem GETDATA R_var_name value

Get the value of a variable in an R workspace. GETDATA is a special method implemented for use with the R DCOM server.

R_var_name
The name of a variable that exists in an R workspace.
variable
The name of an STx variable that will be assigned the value of R_var_name. The variable can receive string or number data.
table
The name of an STx table to receive values from R_var_name. Note that a table can only receive vector or matrix data.
index
The zero-based index of the table field to receive the first column of R_var_name.
count
The number of fields into which the data from R_var_name should be copied.
value
The name of an STx value item that will be assigned the value of R_var_name. The value item can receive string, number, vector or matrix data.

R

R is a language and environment for statistical computing and graphics. You can find more details on their homepage: http://www.r-project.org/

STx can communicate with R using the DCOM interface implemented in STx as a shell item (DCOM).

Note that if you are running R 2.2 or greater, you will need the 2.0 R (D)COM server.

Navigation menu

Personal tools