Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example file for Sublime Text for R tutorial
# TITLE: R in Sublime Text 2 Demonstration
# AUTHOR: Tom Schenk Jr.
# DATE: May 15, 2012
# R as a calculator
2 + 2 # After you adjust the keybindings
sqrt(9) # Syntax should differentiate between function and variable.
sin(pi) # See if there is a floating point issue.
# Install Packages
install.packages(c("ggplot2","reshape"), repos="")
# After adjusting keybindings, you can move your cursor to line 16, then type CTRL+ALT+R to execute it.
hist(mtcars$gear) # A new window will open with the graph.
# Select multiple lines of text, then type CTRL+SHIFT+R to execute it.
mt <- ggplot(mtcars, aes(mpg, wt, color=factor(cyl))) + geom_point()
mt + facet_grid(vs ~ am)
# This is a function
fibonacci <- function(digits){ # Place the cursor on line 24 and press CTRL+SHIFT+[ to fold the code
fib <- c(0,1) # Typing CTRL+SHIFT+ALT+R will execute the code between the curly brackets.
for(i in 3:digits){
fib[i] <- fib[i-1] + fib[i-2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.