Skip to content

Instantly share code, notes, and snippets.

View ramnathv's full-sized avatar

Ramnath Vaidyanathan ramnathv

View GitHub Profile
@ramnathv
ramnathv / diet.r
Created August 24, 2010 01:44 — forked from diegovalle/diet.r
########################################################
##### Author: Diego Valle Jones
##### Website: www.diegovalle.net
##### Date Created: Mon Mar 01 18:51:27 2010
########################################################
#1. For what foods are Americans and Mexicans outliers
#2. Partition the data around medoids to classify the
#countries of the world according to what they eat
library(ggplot2)
plot.heat <- function(tmp,state.map,z,title=NULL,breaks=NULL,cex.legend=1,bw=.2,col.vec=NULL,main=NULL,plot.legend=TRUE, ...) {
tmp@data$zCat <- cut(tmp@data[,z],breaks,include.lowest=TRUE)
cutpoints <- levels(tmp@data$zCat)
if (is.null(col.vec)) col.vec <- heat.colors(length(levels(tmp@data$zCat)))
cutpointsColors <- col.vec
levels(tmp@data$zCat) <- cutpointsColors
cols <- as.character(tmp$zCat)
##cols <- "white"
plot(tmp,border=cols, lwd=bw,axes = FALSE, las = 1,col=as.character(tmp@data$zCat),main="A", ...)
if (!is.null(state.map)) {
@ramnathv
ramnathv / printfun.Rnw
Created February 27, 2012 14:05 — forked from yihui/printfun.Rnw
a hook to print highlighted source of a function
\documentclass{article}
<<hook-printfun, echo=FALSE>>=
knit_hooks$set(printfun = function(before, options, envir) {
if (before) return()
txt = capture.output(dump(options$printfun, ''))
## reformat if tidy=TRUE
if (options$tidy) txt = formatR::tidy.source(text = txt, output = FALSE)$text.tidy
con = textConnection(txt)
on.exit(close(con))
@ramnathv
ramnathv / minify
Created June 24, 2012 08:55 — forked from benpickles/minify
Swiftly concat and minify JavaScript files from the command line
#!/usr/bin/env ruby
dry_run = ARGV.delete('--dry-run')
force = ARGV.delete('--force')
if ARGV.empty?
puts <<-USAGE
minify, swiftly concat and minify JavaScript files from the command line
Pass a single argument to create a .min.js version:

#HTML presentation tools

There are many HTML presentation tools and they are all created for slightly different reasons. Here's an overview. Please let me know if I forgot any.

##CSSS

CSS-based SlideShow System

@ramnathv
ramnathv / gist:4014474
Created November 5, 2012 00:07 — forked from Gregg/gist:968534
Code School Screencasting Framework

Screencasting Framework

The following document is a written account of the Code School screencasting framework. It should be used as a reference of the accompanying screencast on the topic.

Why you should care about screencasting?

You're probably aren't going to take the time to read this document if you're not interested, but there are a lot of nice side effects caused by learning how to create quality screencasts.

  1. Communicating more effectively - At Envy Labs we produce screencasts for our clients all the time. Whether it's demoing a new feature or for a presentation for an invester, they're often much more effective and pleasent than a phone call or screen sharing.
@ramnathv
ramnathv / watchr.R
Created January 4, 2013 20:23 — forked from dill/watchr.R
# watch all .Rmd files in a directory, if any change, knit them
library(knitr)
# use watch from Hadley's testthat package
library(testthat)
watchr<-function(path){
# the path supplied here can just be something like "./"
library(shiny)
# Sample database
patient <- data.frame(PatientID = LETTERS[1:5],
Name = letters[1:5],stringsAsFactors=FALSE)
record <- data.frame(PatientID = rep(patient$PatientID,3))
record$RecordID <- paste(PatientID=patient$PatientID,
sample(LETTERS[1:26],15),sep="_")
record$Title <- sample(letters[1:26],15)
# Here a set of instructions corresponding to each code lesson is made into a dataset codelist
ID=as.numeric() # id of code lesson
instruct=as.character() # instructions for code lesson
subhead=as.character() # subheading for code lesson
i=1
ID[i]=i
subhead[i]="Simple R Expressions: Addition"
instruct[i]=paste('Try simple math','Type the command below','','1+1','',sep="\n")
@ramnathv
ramnathv / server.r
Last active September 10, 2017 00:41 — forked from wch/server.r
data_sets <- c("mtcars", "morley", "rock")
shinyServer(function(input, output) {
# Drop-down selection box for which data set
output$choose_dataset <- reactiveUI(function() {
selectInput("dataset", "Data set", as.list(data_sets))
})
# Check boxes