Procedures and functions
All R statements are evaluated in the R Global Environment, more often known as the user's workspace.
In general, the procedures and functions of r do not fail in case of R parsing or evaluation errors but set an internal status variable that can be read with Rerrcode. To make sure that an operation has been performed correctly, it is recommended to check the value of this variable after each call.
Clear the last error code and message.
|
|
Get the last error code.
|
|
Get the last error message.
|
|
Evaluate R statements.
|
|
Terminate an R session.
|
|
Get the resulting array of an R expression.
|
|
Get the boolean value of an R expression.
|
|
Get the integer value of an R expression.
|
|
Get the real value of an R expression.
|
|
Get the string value of an R expression.
|
|
Initialize an R session.
|
|
Evaluate R statements and print the result.
|
|
Assign a Mosel value to an R object.
|
|
Assign a Mosel array to an R data.frame object.
|
|
Evaluate an R script file.
|
I/O drivers
In order to simplify access to R this module provides a driver that is designed to be used in initializations blocks for both reading and writing data, providing the same functionalities as the Rget and Rset functions.
Driver rws
rws:
The driver can only be used in `initializations' blocks. It does not take any argument and provides access to the R workspace.
In the block, each label entry is understood as one or more R statements. For 'from' blocks, if the label contains more than one statement, the value from the last one is returned. For 'to' blocks, the label must contain only one expression.
This driver requires an existing R session, therefore it is necessary to initialize R (either by calling function Rinit or any of the other module functions that create an R session) before using it.
Example:
initok:=Rinit ! Initialize R initializations to "r.rws:" ! Send data to R scalarvar as "val" arrayvar as "arr" end-initializations initializations from "r.rws:" ! Get data from R backscalar as "val" backarr as "arr" end-initializations
Troubleshooting
This section describes some known issues and possible solutions.
- When running a model in Windows, a dialog is shown with title 'Unable to locate component' and content 'The application has failed to start because Rlapack.dll was not found...'.
This may occur with Windows 2003. Please add your R binary directory (usually 'C:\Program Files\R\R-3.x.x\bin\i386' or 'C:\Program Files\R\R-3.x.x\bin\x64' to the system PATH environment variable. - When an R session is initialized in Windows, R installs a console handler to detect Ctrl-C events which may prevent Mosel from properly detecting these same events itself.
- In Linux, R may fail to load if the dynamic libraries in $R_HOME/lib cannot be found by the dynamic linker. In this case, please add $R_HOME/lib to the LD_LIBRARY_PATH environment variable.
- This module is not compatible with Mosel security restrictions, therefore it would fail to load if Mosel is run in restricted mode.
- On Mac OS X, if the R release being used is linking the Apple CoreFoundation library, then this module can only be successfully initialized from the main thread of the process in which Mosel is running (because the CoreFoundation library can only be loaded from the main thread of a process). So, for example, the module would fail to load R from an mmjobs submodel. In this case, it is possible to overcome this issue by setting the environment variable DYLD_INSERT_LIBRARIES to /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (use the correct path to the CoreFoundation library on your system) before launching the Mosel process, thus forcing an anticipated loading of the CoreFoundation library at process creation.
© 2001-2023 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.