R script window
Menu location: Continue in R on the right-click menu of a result in a report, the R button on the toolbar of a report, or File > New Script for an empty script.
The R script window holds an R script and runs it with the R installed on your computer. Continue in R on a result writes the script of that result: the data as the analysis used them, read from the workbook, the settings, and the analysis as the R section of its help topic shows it. The R button on the toolbar of a report does the same for the result the cursor is in, or for the latest result when the cursor is in none. The script is short and plain, so that you can read it, change it and run it again, or take it to R or RStudio. Every analysis whose help topic has an R section has such a script; for the others, Open data and settings in R gives the data and settings for you to add the analysis.
The script runs as soon as it opens, and what R prints appears below it, with the files the run wrote, charts among them, listed as links. Run on the toolbar runs the script again after you edit it; a run still going is stopped first. Clear output, under the arrow at the end of the toolbar, clears what R printed, and Output folder beside it opens the folder the script writes its files to, the R folder of your StatsDirect documents. The box at the bottom right names the language of the script, R for these scripts, and Run beside it does the same. What R prints appears as an R session shows it: each command after its prompt, with its output under it. Open in R saves the script as an R file and opens it in RStudio when that is installed, else in R's own window, run in its console and open in its editor, for you to go on in R itself. AI assistance opens the Script AI pane, where you can ask about the script, what R printed and the methods through your own ChatGPT account, as the Script AI topic describes.
Save and Save As on the File menu keep the script as an R file, which R and RStudio open, and Open brings a saved script back. Cut, Copy, Paste and Find work on the script as in any editor.
The first lines of a script say which workbook and sheet its data came from and when they were read, and note any column that has changed in the workbook since the analysis ran, or could not be read, so that you can put its values in by hand. If no R is installed, StatsDirect offers to install it when a script is first run.
Help on this window opens this topic while the window is empty; once a script of a result is in it, Help opens that result's topic, whose R section the script follows.