Writing R scripts in Statistica

Writing R scripts in Statistica

book

Article ID: KB0074360

calendar_today

Updated On:

Products Versions
Spotfire Statistica 13.0 and higher

Description

When R (an open software) is integrated properly with Statistica, you can write R script in Statistica Macro directly. Here is our R integration white paper. This article shows how to start a R scripting session and how to use R scripting in an analysis configuration under Enterprise. 
 

Issue/Introduction

Writing R scripts in Statistica

Environment

Windows

Resolution

1.Under "Home", click "New" (not the drill-down but the paper icon circled in red) to open a new document

2. Under the "Macro" tab, select "R" as the Scripting Language

3. Click "OK" to open the script editor to start R scripting:

To write R script in an analysis configuration in Enterprise:

1. Right click the data configuration that you want to use as the analysis data and select "New Analysis Configuration off this Data" 

2. An analysis configuration will be created, enter the name (e.g. "Adstudy 8") and select the "R Analysis" as the Type (The node icon will change to indicate it as R analysis)

3. Click "Next Step" to configure all other options and write R scripts under the R script. In the R script example below, "ActiveDataSet" refers to the data returned by the data configuration and running the analysis will return the structure of the data, create histograms from Variables 3~6 and create a "Downstream results" spreadsheet containing a single column vector of integer value 1~10.

4. Once the R analysis configuration is created, you can run it just as any other type of analysis configuration.

Or you can create customized R node in a workspace and deploy the workspace to Enterprise:

Click "File | Open Examples | Workspaces | Example_Lasso" to access the example, right click the R node to select "Edit Code" to view the R scripts.