Skip to content

Instantly share code, notes, and snippets.

View tomschenkjr's full-sized avatar

Tom Schenk Jr tomschenkjr

View GitHub Profile
[
// Modified Sublime-REPL keybindings for an "R-friendly" set of shortcuts.
// Copy and paste this text into the Key Bindings - User (under Preferences menu).
// For more information, see http://tomschenkjr.net/2012/05/17/using-sublime-text-2-for-r/
// Executes a selection of text in REPL, latter only displays code and does not execute
{ "keys": ["ctrl+shift+r"], "command": "repl_transfer_current", "args": {"scope": "selection"}},
{ "keys": ["ctrl+shift+r", "r"], "command": "repl_transfer_current", "args": {"scope": "selection", "action":"view_write"}},
// Executes the entire file (build) in REPL, latter only displays code and does not execute
@tomschenkjr
tomschenkjr / sublime-path
Last active October 5, 2015 18:58
Setting PATH for Sublime Text 2
{
"default_extend_env":{"PATH":"{PATH};C:\\Users\\user_name\\Documents\\R\\R-2.14.1\\bin\\x64"}
}
@tomschenkjr
tomschenkjr / send-to-R-new-line.sublime-macro
Created June 5, 2012 17:20
Send a selection of code to R using SublimeREPL and move cursor to new line
// Purpose: This is a macro which will send a selection of text to sublimeREPL.
// Note: Add this to your macros, which can be accessed from Tools > Macros or saving to your Sublime Text Packages folder.
[
{"command": "repl_transfer_current", "args": {"scope": "selection"}}
{"command": "move", "args": {"by": "lines", "forward": true}}
]
@tomschenkjr
tomschenkjr / R-in-sublime-text-2-demonstration.R
Created June 5, 2012 18:47
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
@tomschenkjr
tomschenkjr / Remove-period-as-R-separator
Last active October 6, 2015 20:38
Remove period (.) as a separator in R script.
// Characters that are considered to separate words – does not include periods.
// Place comma at the end of the line if there are multiple keybindings.
{"word_separators": "/\\()\"‘-:,;~!@#$%^&*|+=[]{}`~?"}
@tomschenkjr
tomschenkjr / getuser.php
Created September 5, 2012 14:32
Create a dropdown box to query data and display in table on HTML page
<?php
$q=$_GET['q'];
$con = mysql_connect('mysql.tomschenkjr.net', 'tsjr_visitor', 'tsjr_visitor_password');
if(!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tsjr_sandy", $con);
@tomschenkjr
tomschenkjr / ggplot2-tutorial-2.R
Created October 29, 2012 18:37
Chicago Data Visualization ggplot2 Tutorial 2 Script
# LOAD UP GGPLOT2
library(ggplot2)
# PROPER TIME SERIES DATA
str(economics) # Explore the economics data set that comes with ggplot2.
# PLOT THE RELATIONSHIP OF UNEMPLOYMENT AND TIME
p <- ggplot(economics, aes(x = date, y = unemploy))
p + geom_line()
@tomschenkjr
tomschenkjr / ggplot2-tutorial-hw-maps.R
Created November 7, 2012 22:55
ggplot2 Workshop Homework for Maps
# TITLE: ggplot2 Workshop Homework for Maps
# AUTHOR: Tom Schenk Jr.
# DATE CREATED: November 7, 2012
# DATE MODIFIED: None
# PURPOSE: Create maps using R and ggplot2 library.
# LIBRARIES: ggplot2, maptools
library(ggplot2)
library(maptools)
@tomschenkjr
tomschenkjr / ggplot2-tutorial-3.R
Created November 12, 2012 20:45
Chicago Data visualization ggplot2 Tutorial 3 Script
# Let's customize our plot outputs. First, load the library.
library(ggplot2)
# Plot something simple
p <- ggplot(mtcars, aes(x=cyl, y=mpg)) + geom_point(aes(color=qsec, size=wt))
# Change axis
p + scale_y_continuous(limits=c(0,40))
@tomschenkjr
tomschenkjr / reshape-tutorial.R
Created November 19, 2012 01:56
Chicago Data Visualization reshape Tutorial Script
# Install reshape package. You will be asked to pick a server.
install.packages("reshape")
# We're going to also use ggplot2, so let's install that as well:
install.packages(c("reshape","ggplot2")) # In R, c() concatenates inputs as a vector
# You will always need to load the libraries after installing the package.
library(reshape)
library(ggplot2)