Export to R or Python

Data desk can write out R or Python code to reproduce many plots and analyses. Here are basic instructions:

First time:

In a window’s global hyperview menu, choose Export > Data

Data Desk will clean your data to R standards, replacing missing values with “NA,” converting variable names to be R legal. It saves the data file as tab-delimited text.

Once the data file is saved, choose Export > R > to File. (Or, equivalently, Export > Python > to File.) Data Desk creates a text file that holds the commands to reproduce the plot or analysis in the Data Desk window.

You can then click out of Data Desk and open the file of commands in its appropriate environment.

Subsequent analyses and plots using the same data can just be copied to the Clipboard (Export > R > to Clipboard) and pasted into the editor window.

You can send a sequence of Data desk commands to R or Python. Chose Batch Export from the menu. Data Desk opens a batch export window. Now drag the icons of the plots or analyses you wish to export into the export list. Each Data Desk plot or analysis window has its own icon. You can find those in the Results folder in the File (usually in the upper right corner of your desktop). You can drag any number of icons into the batch export window at once.

Alternatively, look in the title bar of the results window for their icon alias. (You can see an icon alias in the upper right of the batch export window on the right.) Drag a window’s icon alias to the Batch Export List to add it to the program you are exporting.

Now when you save your program as an R or Python script, Data Desk will save a program with all of the selected commands.

If the data file has been changed (e.g. by computing residuals and adding them to the data file), you’ll need to export the data again. (It’s never a bad idea to export the data just be sure.)

Exported programs are an effective way to record your analysis and to communicate it to others who may not be using Data desk. This is also an excellent way to learn new statistics and programming languages. The capable data analyst and data scientist typically knows and uses several statistics programs, choosing among them according to which fits his or her current needs.