Integrating R and BBEdit on Mac OS X
This document has been superceded by Statistical Software & Text Editors on Mac OS X as of September 16, 2014. Please consult this newer document instead.
Last revised: 8 February 2013
This page provides software extensions to add support for R to BBEdit or TextWrangler on Mac OS X. Integrating R with either BBEdit or TextWrangler will make working with R more efficient, saving time and making commands clearer.
- R is a powerful open source statistical software package.
- BBEdit is a popular commercial text editor.
- TextWrangler is a free program similar to and by the authors of BBEdit.
Language Module
This language module adds support for syntax coloring, auto-completion, function browsing, and code folding. Name your files with the extension ".r" to activate these features.
Place this file in ~/Library/Application Support/BBEdit/Language Modules or ~/Library/Application Support/TextWrangler/Language Modules.
Scripts
These scripts allow one to control R from within BBEdit or TextWrangler.
Place these files in ~/Library/Application Support/BBEdit/Scripts or ~/Library/Application Support/TextWrangler/Scripts.
Once placed in the appropriate folder, these will appear in the Scripts menu in BBEdit or TextWrangler. To assign keyboard shortcuts, such as "Command-R" to the "Run in R" script, select "Scripts" from the "Palettes" submenu of the "Window" menu.
The "Run" script will execute the selected text, or, if none is selected, the line in which the cursor is placed.
The "Run All" script will paste and run the contents of the window in the R console.
The "Source" script will have R execute the file you are currently writing. Better for debugging than "Run All", R will print line numbers when it finds errors. This script does not save the file, so if you wish to run the script as written on your screen, save your changes before running the Source script.