This page provides a brief guide to using R in Sublime Text on Mac. This guide covers setup, use, and customization. R is a programming language and system for statistical computing. Sublime Text is a smart text editor.
SETUP
You need three tools to use R in Sublime Text: R, Terminus, and SendCode. Terminus is a package that allows for you to open a terminal in Sublime Text. SendCode is a package that makes it easy to send R code to the terminal.
To use R in Sublime Text, you need to create a file, set the syntax to R, and build. You can make Sublime Text your default editor for R code after creating your first file.
Use R:
Open Sublime Text
Press Command + N
Press Command + Shift + P
Search "Set Syntax: R Extended"
Press Enter
Write your R code
Open terminal in Sublime Text:
Press Command + Shift + P
Search "Terminus: Open Default Shell in Panel"
Press Enter
Open R in terminal:
Select the panel that opened in Step G
Type "R"
Press Enter
Build:
Select the script that you wrote in Step F
Send source file with Command + B
Send selected code with Command + Enter
Make Sublime Text your default editor:
Save R code
Find the .R file on your Mac
Hold Control and select the .R file
Select "Get info"
Select "Sublime Text" from the "Open with" menu
Select "Change all"
Close window
SNIPPETS
Sublime Text can be customized with snippets. A snippet is a block of code that can be pasted by entering a predefined combination of keys. Snippets make writing R code faster. The following steps will create and use a snippet called "seed" containing "set.seed(12)":
Create snippet:
Open Sublime Text
Select "Tools" from the menu
Select "Developer"
Select "New Snippet"
Replace the existing text with the following:
seedsource.r