1. Home
  2. Submit R Script

Submit R Script

Select menu: Run | Submit R Script

Use this to submit a set of commands to R and then read the output generated from the run back into Genstat.

  1. From the menu select Run | Submit R Script.

To use this menu the R software must be installed on the current system and the location of R must be specified within the R setup menu. To execute commands within R, Genstat creates an R script file (.r) that contains the commands for setting the working directory, loading any data and running additional R commands (supplied in another file or using the Edit R script menu). By default, this file is executed in R using the Rterm.exe executable, however, the executable used can be changed via the setup menu. The script is executed within Genstat using the RXGENSTAT procedure. To set additional options before running the script click Options.

Available data

This lists data structures that can be exported to R. The dropdown list can be used to display the data structures within the available data list based on their type (e.g. variates, factors, scalars etc…). Double-click a name to copy it to the Data to export field or type the name. You can transfer multiple selections from Available data by holding the Ctrl key on your keyboard while selecting items, then click to move them all across in one action.

Data to export

Specifies data to be exported from Genstat to R. The data structures can either be a list of factors, variates and texts of equal length, a list of scalars, or a single matrix. When the script is run the data are first saved to an R data (rda) file using the EXPORT procedure. The name of this file should be supplied using the Export R data file (rda) option and then the data can then be accessed within an R script. For example, if are data exported into a file called idata.rda, then within the R script the data can be accessed as idata$x etc…

Export R data file (rda)

Specifies the name of the R data file that the Genstat data are to be exported into.

Working directory

Sets the working directory for Genstat and R. Files located in this directory can be specified using just their names; files in other directories need to be specified using their full pathname.

R Script

Specifies the R script that is to be run.

R Script file Enter the name of an R script file (.r) containing the R script.
Specify R Commands Lets you enter the R script by clicking on the Edit R Script button.

Output file

Specifies a filename to save the output generated by R.

Import R data file (rda)

Specifies the name of an R data file saved within the R script that contains data that are to be imported back into Genstat. The data are imported into Genstat using the IMPORT procedure and a pointer to this data can be saved using the Save pointer to import data option.

Save pointer to import data using

When selected, this provides the space to enter the name of an identifier to save as a pointer to the imported data.

R setup

Opens a dialog where you can specify the location of the R executables and additional command line options for R.

Action buttons

Run Submit the script to R.
Cancel Close the menu without further changes.
Options Opens a dialog where additional options and settings can be specified.
Defaults Set the menu settings back to the default settings. Clicking the right mouse on this button produces a pop-up menu where you can choose to set the options using the currently stored defaults or the Genstat default settings.

Action Icons

Pin Controls whether to keep the dialog open when you click Run. When the pin is down  the dialog will remain open, otherwise when the pin is up  the dialog will close.
Restore Restore names into edit fields and default settings.
Clear Clear all fields and list boxes.
Help Open the Help topic for this dialog.

See also

Updated on March 11, 2019

Was this article helpful?