Custom Dialogs for Generating Explicit R Code

Custom dialogs can be used to generate BEGIN PROGRAM R-END PROGRAM blocks of command syntax containing explicit R code. Within a BEGIN PROGRAM R block you have access to both the R programming language and a set of functions specific to IBM® SPSS® Statistics that are provided with the IBM SPSS Statistics - Integration Plug-in for R.

As an example, we will create a custom dialog that runs the R boxplot function. The function has some features that differ from those available with IBM SPSS Statistics boxplots.

Our custom dialog will generate code to call the R boxplot function with the signature shown here.

boxplot(formula, data, xlab, ylab, main, horizontal, col) 
  • formula specifies an expression, such as depvar~catvar, where depvar is a numeric vector whose values will be grouped by catvar.
  • data is a data frame containing the values of the variables specified in formula.
  • xlab and ylab are the labels for the horizontal axis and vertical axis respectively.
  • main specifies the plot title.
  • horizontal specifies whether the boxplot should be displayed horizontally.
  • col contains one or more colors to use to color the boxes.

Next