Skip to content

Instantly share code, notes, and snippets.

@jeffreyhorner
jeffreyhorner / .gitignore
Last active December 21, 2015 19:39 — forked from hadley/.gitignore
.Rproj.user
.Rhistory
.RData
*.Rproj
*.html
@jeffreyhorner
jeffreyhorner / server.R
Created December 14, 2012 21:48
Reactivity #3
library(shiny)
shinyServer(function(input, output) {
re <- reactive(function(){
cat("re called\n",file=stderr())
input$n
})
output$ntext <- reactiveText(function() {
cat("output$ntext called\n",file=stderr())
@jeffreyhorner
jeffreyhorner / server.R
Created December 6, 2012 03:48
simpleTab with visible tab id
library(shiny)
shinyServer(function(input, output) {
cat('shinyServer called\n',file=stderr())
output$foo <- reactivePrint(function(){
cat('output$foo called\n',file=stderr())
input
})
runIfVisible <- function(visibleTab,val,expr){
@jeffreyhorner
jeffreyhorner / server.R
Created December 4, 2012 18:45
simpleTab
library(shiny)
shinyServer(function(input, output) {
cat('shinyServer called\n',file=stderr())
output$foo <- reactivePrint(function(){
cat('output$foo called\n',file=stderr())
input$n
})
output$afunc <- reactivePrint(function() {
@jeffreyhorner
jeffreyhorner / aedotplot.r
Created March 7, 2012 21:59 — forked from harrelfe/aedotplot.r
Adverse Event Dotplot for R
require(lattice)
library(RMySQL)
## The following functions are in the HH package
panel.ae.dotplot <-
function (x, y, groups, ..., col.AB, pch.AB, lower, upper)
{
panel.num <- panel.number()
if (panel.num == 1)
panel.ae.leftplot(x, y, groups = groups,
col = col.AB, pch = pch.AB, ...)
@jeffreyhorner
jeffreyhorner / aedotplot.R
Created March 7, 2012 17:27
Adverse Events Plot
require(lattice)
library(RMySQL)
## The following functions are in the HH package
panel.ae.dotplot <-
function (x, y, groups, ..., col.AB, pch.AB, lower, upper)
{
panel.num <- panel.number()
if (panel.num == 1)
panel.ae.leftplot(x, y, groups = groups,
col = col.AB, pch = pch.AB, ...)
@jeffreyhorner
jeffreyhorner / aedotplot.R
Created March 7, 2012 17:23
Adverse Events Dotplot
require(lattice)
## The following functions are in the HH package
panel.ae.dotplot <-
function (x, y, groups, ..., col.AB, pch.AB, lower, upper)
{
panel.num <- panel.number()
if (panel.num == 1)
panel.ae.leftplot(x, y, groups = groups,
col = col.AB, pch = pch.AB, ...)
if (panel.num == 2)
toSeconds <- function(x){
if (!is.character(x)) stop("x must be a character string of the form H:M:S")
if (length(x)<=0)return(x)
unlist(
lapply(x,
function(i){
i <- as.numeric(strsplit(i,':',fixed=TRUE)[[1]])
if (length(i) == 3)
i[1]*3600 + i[2]*60 + i[3]
library(stringr)
library(evaluate)
library(sinartra)
is.pass <- function(x) inherits(x,'pass')
#' Parse route (with parameters) into regular expression.
#'
#' @param route route url.
#' @return
#' \item{match}{regular expression to match route}
#' \item{params}{parameter names}
@jeffreyhorner
jeffreyhorner / Twitchimps.R
Created December 17, 2010 23:04
Maps your follower names to R variables located in an environment on your search path. Each variable contains a list of influence scores for that follower.
library(twitteR)
library(infochimps)
library(datamap)
infochimps('YOUR_API_KEY')
# Creates a new mapper, similar to an OO class
newMapper(type='twitchimps:influence',
# Init is called once during newMap(). Note that