Skip to content

Latest commit

 

History

History
71 lines (36 loc) · 8.98 KB

FUNCTIONS.md

File metadata and controls

71 lines (36 loc) · 8.98 KB

New Excel functions

XLRCODERun R code in a local environment and transfer values from and to Excel. Function memory is cleared after calculation.
XLRCODE_ENVRun R code in a pre-specified environment and transfer values from and to Excel
XLRSCRIPTRun R script in a local environment and transfer values from and to Excel. Function memory is cleared after calculation.
XLRSCRIPT_ENVRun R script in a pre-specified environment and transfer values from and to Excel
XLRFUNCCall an R function in a local environment and transfer values from and to Excel
XLRFUNC_ENVCall an R function in a pre-specified environment and transfer values from and to Excel

XLRCODE

Run R code in a local environment and transfer values from and to Excel. Function memory is cleared after calculation.

ReturnFunction returns the visible result of the last command of the code. In case it is not  visible, function returns TRUE.
ParametersDescription
CommandsR code
[ParamsList]...Sequence of optional paired parameters, where the first parameter is a valid variable name (as a text string) and the second parameter is its value. Variable names with the (optional) following suffixes are coerced to specific data types: (n) => double, (s) => string, (d) => date, (df) => data frame. Other coercions are available at the "Data types" worksheet.

Example: Concatenate two strings placing a separator in-between them

image

XLRCODE_ENV

Run R code in a pre-specified environment and transfer values from and to Excel.

ReturnFunction returns the visible result of the last command of the code. In case it is not  visible, function returns TRUE.
ParametersDescription
[Environment]Name of the environment in which to run the R code. If omitted or empty, code is run inside Global environment.
CommandsR code
[ParamsList]...Sequence of optional paired parameters, where the first parameter is a valid variable name (as a text string) and the second parameter is its value. Variable names with the (optional) following suffixes are coerced to specific data types: (n) => double, (s) => string, (d) => date, (df) => data frame. Other coercions are available at the "Data types" worksheet.

Example: Concatenate two strings placing a separator in-between them

image

XLRSCRIPT

Run R script in a local environment and transfer values from and to Excel. Function memory is cleared after calculation.

ReturnFunction returns the visible result of the last command of the script. In case it is not  visible, function returns TRUE.
ParametersDescription
ScriptPathR script file path
[ParamsList]...Sequence of optional paired parameters, where the first parameter is a valid variable name (as a text string) and the second parameter is its value. Variable names with the (optional) following suffixes are coerced to specific data types: (n) => double, (s) => string, (d) => date, (df) => data frame. Other coercions are available at the "Data types" worksheet.

Example: Concatenate two strings placing a separator in-between them

XLRSCRIPT_ENV

Run R script in a pre-specified environment and transfer values from and to Excel.

ReturnFunction returns the visible result of the last command of the script. In case it is not  visible, function returns TRUE.
ParametersDescription
[Environment]Name of the environment in which to run the R code. If omitted or empty, code is run inside Global environment.
ScriptPathR script file path
[ParamsList]...Sequence of optional paired parameters, where the first parameter is a valid variable name (as a text string) and the second parameter is its value. Variable names with the (optional) following suffixes are coerced to specific data types: (n) => double, (s) => string, (d) => date, (df) => data frame. Other coercions are available at the "Data types" worksheet.

Example: Concatenate two strings placing a separator in-between them

XLRFUNC

Call an R function in a local environment and transfer values from and to Excel. Function memory is cleared after calculation.

ReturnFunction returns the result of the R function called.
ParametersDescription
FunctionNameName of the function to be called. Consider specifying the whole function path to avoid confusion.
[AfterFunction]In case the function called returns a complex structure and one wants to access a nested element, this parameter value is appended to the result object, i.e. [1]
[ParamsList]...Sequence of optional paired parameters, where the first parameter is a valid variable name (as a text string) and the second parameter is its value. In case one wants to list arguments in the default order received by the function, without identifying them, provide "..." as a parameter followed by the desired arguments. Mixing identified and non-identified arguments is possible as long as all non-identified parameters come at the end. Moreover, one can pass a string with the literal specification of parameter names and their respective arguments as in R code. For that, one should pass "*" as the =XLRFUNC parameter name and the literal R expression as its value. Variable names with the (optional) following suffixes are coerced to specific data types: (n) => double, (s) => string, (d) => date, (df) => data frame. Other coercions are available at the "Data types" worksheet.

Example: Concatenate two strings placing a separator in-between them

XLRFUNC_ENV

Call an R function in a pre-specified environment and transfer values from and to Excel.

ReturnFunction returns the result of the R function called.
ParametersDescription
[Environment]Name of the environment in which to call the R function. If omitted or empty, function is called inside Global environment.
FunctionNameName of the function to be called. Consider specifying the whole function path to avoid confusion.
[AfterFunction]In case the function called returns a complex structure and one wants to access a nested element, this parameter value is appended to the result object, i.e. [1]
[ParamsList]...Sequence of optional paired parameters, where the first parameter is a valid variable name (as a text string) and the second parameter is its value. In case one wants to list arguments in the default order received by the function, without identifying them, provide "..." as a parameter followed by the desired arguments. Mixing identified and non-identified arguments is possible as long as all non-identified parameters come at the end. Moreover, one can pass a string with the literal specification of parameter names and their respective arguments as in R code. For that, one should pass "*" as the XLRFUNC parameter name and the literal R expression as its value. Variable names with the (optional) following suffixes are coerced to specific data types: (n) => double, (s) => string, (d) => date, (df) => data frame. Other coercions are available at the "Data types" worksheet.

Example: Concatenate two strings placing a separator in-between them

XLRDATE

  • Convert Excel dates to R dates or vice-versa.