Skip to content

Instantly share code, notes, and snippets.

View webbedfeet's full-sized avatar

Abhijit Dasgupta webbedfeet

View GitHub Profile
package mostDownloads bestRank week tot rank
shiny 1018 70 2013-06-10 1018 70
RColorBrewer 4376 4 2013-04-29 3408 4
scales 3976 6 2012-12-10 1571 6
scales 3976 6 2012-12-03 1720 6
reshape2 4330 6 2012-12-17 1312 6
reshape2 4330 6 2013-01-07 2199 6
reshape2 4330 6 2013-05-13 3660 6
proto 3902 3 2012-12-24 963 3
ggplot2 5291 1 2013-03-25 3160 1
xlsxToR <- function(file) {
require(XML)
require(plyr)
suppressWarnings(file.remove(tempdir()))
file.copy(file, tempdir())
new_file <- list.files(tempdir(), full.name = TRUE, pattern = basename(file))
new_file_rename <- gsub("xlsx$", "zip", new_file)
file.rename(new_file, new_file_rename)
#'% How to format plots for publication using `ggplot2` (with some help from Inkscape)
#'% Rosemary Hartman
#'% 13-11-20 19:51:47
#'
#' ***The following is the code from a presentation made by Rosemary Hartman to
#' the [Davis R Users' Group](http://www.noamross.net/davis-r-users-group.html).
#' I've run the code through the `spin` function in `knitr` to produce this post.
#' Download the script to walk through [here](https://gist.github.com/noamross/7576436)***
#'
#' First, make your plot. I am going to use the data already in R
{
"scope": "source.r",
"completions":
[
"abline",
"abs",
"anova",
"anova.glm",
"anova.lm",

This is a short demo of how to use brew and knitr in combination with each other to get the best of the templating facilities in brew and the literate programming functions in knitr. The main idea is to write a function brew_knit

# Preprocess template using brew and then run knit on the output
brew_knit <- function(template, params, ...){
 brew::brew(template, envir = list2env(params))
 input = gsub(".Rnwe", '.Rnw', template)
 knitr::knit(input)
}
#!/bin/bash
USERNAME=icaoberg
#to kill all the jobs
qstat -u$USERNAME | grep "$USERNAME" | cut -d"." -f1 | xargs qdel
#to kill all the running jobs
qstat -u$USERNAME | grep "R" | cut -d"." -f1 | xargs qdel
@webbedfeet
webbedfeet / tufte
Last active August 29, 2015 14:13 — forked from abresler/tufte
library(dplyr)
library(tidyr)
library(magrittr)
library(ggplot2)
"http://academic.udayton.edu/kissock/http/Weather/gsod95-current/NYNEWYOR.txt" %>%
read.table() %>% data.frame %>% tbl_df -> data
names(data) <- c("month", "day", "year", "temp")
data %>%
group_by(year, month) %>%
@webbedfeet
webbedfeet / Makefile
Last active September 19, 2015 20:53 — forked from lmullen/Makefile
PDF slides and handouts using Pandoc and Beamer
SLIDES := $(patsubst %.md,%.md.slides.pdf,$(wildcard *.md))
HANDOUTS := $(patsubst %.md,%.md.handout.pdf,$(wildcard *.md))
all : $(SLIDES) $(HANDOUTS)
%.md.slides.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -o $@
%.md.handout.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -V handout -o $@
@webbedfeet
webbedfeet / dot_density.R
Created September 29, 2015 04:18 — forked from dsparks/dot_density.R
Dot Density Electoral Map
doInstall <- TRUE
toInstall <- c("XML", "maps", "ggplot2", "sp")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
myURL <- "http://en.wikipedia.org/wiki/United_States_presidential_election,_2012"
allTables <- readHTMLTable(myURL)
str(allTables) # Look at the allTables object to find the specific table we want
stateTable <- allTables[[14]] # We want the 14th table in the list (maybe 13th?)
#source MASTER
setwd("~/your/working/directory") #insert your working directory
#load libraries
library(rgdal)
library(maptools)
library(maps)
library(ggplot2)
library(plyr)
library(grid)