Package 'rGroovy'

Title: Groovy Language Integration
Description: Integrates the Groovy scripting language with the R Project for Statistical Computing.
Authors: Thomas P. Fuller <[email protected]>
Maintainer: Thomas P. Fuller <[email protected]>
License: LGPL-3
Version: 1.3
Built: 2024-11-06 06:13:11 UTC
Source: https://github.com/cran/rGroovy

Help Index


Function prints some information about this package.

Description

Function prints some information about this package.

Usage

About()

Function verifies the existing JRE version is greater than or equal to 1.7 and, if it is not, invokes the stop function with a message.

Description

Function verifies the existing JRE version is greater than or equal to 1.7 and, if it is not, invokes the stop function with a message.

Usage

CheckJRERuntimeVersion(runtime_version)

Arguments

runtime_version

For example, "1.7".


Function evaluates (executes) the groovy script and returns the result.

Description

Function evaluates (executes) the groovy script and returns the result.

Usage

Evaluate(groovyShell = NULL, groovyScript)

Arguments

groovyShell

The groovyShell with which to execute the specified groovy script. Note that the groovyShell can be NULL, however if this is NULL then the Initialize function must have been called so that a global groovyShell instance will be available in the environment otherwise an exception is raised.

groovyScript

The groovy script being executed.

Value

The result of the script execution.

Examples

## Not run: 
 Initialize ()
 Evaluate (groovyScript="print 'Hello world!'")
 
## End(Not run)

Function executes the groovy script and returns the result. Execute differs from Evaluate in that references to Groovy objects are not required. The call to Initialize is not required in order to call this function either however keep in mind that a new instance of groovy.lang.GroovyShell will be used every time this function is called.

Description

Function executes the groovy script and returns the result. Execute differs from Evaluate in that references to Groovy objects are not required. The call to Initialize is not required in order to call this function either however keep in mind that a new instance of groovy.lang.GroovyShell will be used every time this function is called.

Usage

Execute(groovyScript, variables = list())

Arguments

groovyScript

The groovy script being executed.

variables

The variables that will be passed to the binding that is used when the groovyScript is executed.

Examples

## Not run: 
 variables <- list ()

 variables["name"] = "Tom"
 variables["day"]  = "Wednesday"

 groovyScript <- "return \"Hello ${name}, how are you doing? Today is ${day}.\""

 result <- Execute (groovyScript=groovyScript, variables=variables)
 result
 
## End(Not run)

Function sets the global instance of GroovyShell that will be used by the Evaluate function whenever it is called with a NULL GroovyShell parameter.

Description

Function sets the global instance of GroovyShell that will be used by the Evaluate function whenever it is called with a NULL GroovyShell parameter.

Usage

Initialize(binding = NULL)

Arguments

binding

An instance of groovy.lang.Binding.

Examples

## Not run: 
 Initialize ()
 
## End(Not run)

Groovy Scripting Language Integration

Description

Functions that integrate the Groovy scripting language with the R Project for Statistical Computing.

Details

From Wikipedia:

"Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It can be used as a scripting language for the Java Platform, is dynamically compiled to Java Virtual Machine (JVM) bytecode, and interoperates with other Java code and libraries."

One powerful feature this package delivers is that it allows the developer to enhance their R script with Java and Groovy code without necessarily being required to ship jars (see Grape, below). A simple example is included here and advanced examples can be found at the project's homepage.

See Also

rGroovy

Groovy (programming language)

Groovy

Grape

Invoke Dynamic

Examples

## Not run: 
#
# Installation Example
#
# Since this package does not ship with Groovy the user needs to specify the Groovy jars prior
# to using the package -- here's an example how this is accomplished:
#
groovyJars <- list (
    "C:/Temp/groovy.jars/groovy-2.4.5-indy.jar",
    # OTHER JAR FILES...
)

options(GROOVY_JARS=groovyJars)

library(rGroovy)

Execute (groovyScript="print 'Hello world!'")

## End(Not run)