R Scripts as Native Statistica Macros

Statistica recognizes .R (and .S) file extensions as R scripts. Such files can be opened by selecting the File tab and clicking Open. It also registers at the operating system level, .R/.S files as Statistica Macros, and therefore these files can be opened in Statistica from a file browser by double-clicking on them.

R scripts are displayed in slightly modified Statistica Visual Basic Macro windows. Such windows actually contain two scripts: the R script itself and the R Integration Support Macro (R.svb), accessible through two tabs in the upper-left corner (circled on the next image).

There is limited R code highlighting available (strings, language extensions, VB-style comments).

Creating a new R script

You can also create a new R script within Statistica. Select the File menu > New menu > Macro tab, and select the R (requires R Statistical Environment) option button. This option will only be available if R Integration support is installed on your machine.

This will open an empty R script window. You can now type or paste in an R program. R Integration support also includes an optional text file called R.inc, placed into the default installation directory along with R.svb. The contents of the file are copied to the beginning of each new R script created in this manner.

Running R Scripts within Statistica

Click the toolbar button or select the Run > Run Macro menu command or click F5. This action executes the R.svb macro for the currently active R script.

Although breakpoints are not supported for the R script itself, it’s possible to set breakpoints and debug the R.svb macro on the second tab while running the R script.

Note: In order to take advantage of R Integration features described in this document, R scripts should be executed from within Statistica. Although it is possible to develop and debug complex R programs within this environment, it was not specifically designed for these purposes; the R environment itself might be better suited for such activities.