Script AI
Menu location: AI on the toolbar of the R script window, or AI assistance in the report window.
The AI button opens the Script AI pane beside the script window. Ask it about the script, about what R printed, or about the methods and how to go on, and it answers in the conversation and suggests R code. The answers come from ChatGPT through your own ChatGPT account: what you ask and what you choose to share go to OpenAI under your agreement with them, and your plan's allowance for Codex applies. StatsDirect has no account of its own and sends nothing until you press Send. Enter in the question box sends the question; Shift+Enter adds a line. The assistant cannot run R or change your documents; it proposes code for you to run.
On Windows, Use my ChatGPT sets up the connection the first time. StatsDirect downloads OpenAI's own component, about 123 MB, from OpenAI's release on GitHub, checks that it is the file expected, and installs it for your Windows account; then the sign-in page opens in your browser. Your work stays open throughout, and a question you had typed is kept. No API key is needed. You stay signed in from one session to the next until you sign out, through the button at the top of the pane, which also says how you are connected. Your existing ChatGPT chats are not brought in.
Each Send sends your question and recent conversation unless an organisation policy limits sharing. Under Sharing for this session, choose whether to share the current script and its output or the current report, and whether to share workbook data. Before confirming, check every selected document for names, dates of birth, patient identifiers and identifying free text.
On Windows, confirmation covers the documents you select for the current session. Sharing a different script or report requires its own confirmation if that document has not been approved. Share open workbook data covers every open workbook. Opening or closing a workbook requires a new confirmation for that set. Simply moving between open workbooks does not withdraw confirmation. To share only one named workbook, use Worksheet AI Assist.
On Mac, Share workbook data and the workbook picker choose a single workbook. Confirmation is shared across Script AI, Report AI and Learning for the current session. Selecting a different data document or restarting StatsDirect requires confirmation again.
The assistant lists approved workbooks and reads only the worksheet ranges it needs, with at most 32 columns and 4,000 cells in one read. It does not silently sample a larger selection. Workbook names can repeat, so check the workbook, worksheet, range and columns named in the answer. A question uses the documents and versions approved when it was sent; editing or closing a shared workbook while a reply is in progress stops access to stale data. Turning sharing off prevents further reads, but content already shared remains in that conversation.
The reply appears in the conversation as it is written, with headings, lists, tables and R code blocks. Each code block has a Copy button.
In the Windows R script window, review the code suggested by Script AI before choosing Run in this R session. This runs the code locally in the current R session with its existing variables and keeps the text in the script editor. If the assistant read workbook data for the reply, StatsDirect supplies those fixed snapshots. Only the suggested code and its data setup run.
In Report AI, in Script AI on Mac, and in Windows Script AI for C# or Visual Basic, Open in R on a block, or Open R code under the conversation for the last reply, opens a new script window holding the code with what it needs before it: the script as it was shared, the fixed worksheet values the assistant read from each workbook, and the code of earlier replies, each part labelled. Separate read snapshots keep their own workbook, sheet and range information, even when workbooks have the same name. Later edits to a workbook do not replace the values used for that reply. The code opens in the Script tab of a new R window, with its own workspace. Nothing runs until you choose Run, and the status line asks you to review suggested code first.
Copy R code copies the last reply's code for pasting elsewhere. Stop in the AI pane ends the reply; the R console has its own Stop control for a running R calculation. The conversation follows a reply while you are reading its end, and stays where you are if you have scrolled up or selected text.
The pane docks at the right of the window. Pop out makes it a window of its own and Dock brings it back; Close hides it, keeping the conversation and any question not yet sent. Each script has its own conversation, kept while the script is open and gone when it closes; New conversation starts afresh, and what was shared before is not carried into it. If the connection drops, the status line says why and Send connects again.
AI restrictions are off unless an administrator sets them in Windows policy; StatsDirect has no setting of its own for them. The policy value AISecurityLevel, a DWORD under Software\Policies\StatsDirect in HKEY_LOCAL_MACHINE, sets the level for this assistant and for the Learning tutor. Restart StatsDirect after changing it.
Level 1, or no value, is unrestricted: the assistant works as described above.
Level 2 restricts data sharing. Each Send sends only the question you type, and the assistant can consult the method help that comes with StatsDirect. Scripts, R output, reports, workbooks and the earlier conversation stay on your computer, the sharing choices are locked, and the pane says Data sharing is disabled by your organisation. Text typed or pasted into the question still goes to OpenAI, so leave out confidential data.
Level 3 restricts AI. StatsDirect does not connect, sign in or send anything, and the pane says AI restricted by policy. Analysis, R, lessons and help work as usual.
Any other value, or a policy that cannot be read, is treated as level 3. At level 2 an administrator can also require the organisation's ChatGPT Enterprise workspace with the string value ChatGPTWorkspaceId, the UUID of the workspace, under the same key; sign-in to any other workspace or to a personal account is then refused, and a malformed value blocks the connection. The earlier value DisableOnlineTutor, a DWORD other than zero in HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER, still gives level 3, and DisableAIDataSharing, a DWORD other than zero in HKEY_LOCAL_MACHINE, gives level 2.
Help > Learning opens the lesson library, where the same tutor teaches statistics with StatsDirect and R, and Learning Options sets its preferences.