Skip to content

Instantly share code, notes, and snippets.

View jeffreyhanson's full-sized avatar

Jeff Hanson jeffreyhanson

View GitHub Profile
@jeffreyhanson
jeffreyhanson / global.r
Created December 9, 2013 00:04
menu bar attempt in r shiny
library(shiny)
getTool <- function(inputId) {
tagList(
tags$head(tags$script(src = "js/navbar.js")),
tags$html(includeHTML('www/navbar.html'))
)
}
@jeffreyhanson
jeffreyhanson / server.r
Last active August 29, 2015 14:08 — forked from xiaodaigh/server.r
library(shiny)
shinyServer(function(input, output, session) {
# Partial example
output$meh <- renderPrint({
print("Press enter or focusout to update --- ")
print(input$myTextInput )
@jeffreyhanson
jeffreyhanson / geoplots.R
Created April 21, 2015 02:46
generic geoplotting functions
# load deps
library(rgdal)
library(raster)
library(data.table)
library(rgeos)
library(tools)
library(RColorBrewer)
library(dplyr)
library(shape)
@jeffreyhanson
jeffreyhanson / install.R
Last active August 29, 2015 14:23
BIOL2015 installation script
# run
# source('https://gist.githubusercontent.com/paleo13/746682a785e709d475c2/raw/100bbc10033a3a9bd1f2fa804d2b508743e06287/install.R')
# set mirror
chooseCRANmirror(ind=4)
# cran packages
install.packages("devtools")
install.packages('zoo')
install.packages('testthat')
# deps
library(magrittr)
library(dplyr)
library(ggplot2)
library(gridExtra)
# load data
data(iris)
#### Initialization
# set params
stan.chains=4
stan.iter=10000
stan.thin=5
max_treedepth=20
adapt_delta=0.9
# load deps
library(glmnet)
#### Initialization
# set global pars
rm(list=ls())
set.seed(500)
# set user params
n=500
spline_df=5
# load deps
library(snow)
library(plyr)
library(doSNOW)
library(compiler)
data(mtcars)
ratio=cmpfun(
function(x, w) {
return(mean((x$mpg * w) / (x$wt * w)))
}
@jeffreyhanson
jeffreyhanson / DDCalc.R
Last active October 9, 2015 07:05 — forked from JaszzyJas/DDCalc.R
Random DD stuff
## Define function that will convert temperatures to Celcius and divide by 8 [same as * 1/8] (as each measurement represents 1/8 of a day)
#Note: need to add a part here where any value <0 = 0 and not a negative, as heating DD's are calculated only using the 'above the threshold'
extractDD=function(path) {
# extract values and convert to kelvin
vals=(values(raster(path,varname="TMP"))-273.15)/8
# set any numbers < 0 to zero
if (sum(vals<0)>0) {
vals[which(vals<0)]=0
}
# return error if any NAs
Do populations in protected areas have population matrix properties?
====================================================================
## Methods
First, we need to
## Results