Created
June 5, 2012 18:47
-
-
Save tomschenkjr/2876877 to your computer and use it in GitHub Desktop.
Example file for Sublime Text for R tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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="http://streaming.stat.iastate.edu/CRAN/") | |
library(ggplot2) | |
library(reshape) | |
# 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] | |
} | |
print(fib) | |
} | |
fibonacci(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment