Skip to content

Instantly share code, notes, and snippets.

View hinkelman's full-sized avatar

Travis Hinkelman hinkelman

View GitHub Profile
n = 100 # No. of samples per treatment
mean.A = 10 # Mean count for treatment A
mean.B = 5 # Mean count for treatment B
nd = data.frame(Trt = c("A", "B")) # Used in predict( ) function
# Generate example data based on Poisson distribution (mean = variance)
data.pois = data.frame(Trt = c(rep("A", n), rep("B", n)),
Response = c(rpois(n, mean.A), rpois(n, mean.B))
)
@hinkelman
hinkelman / server.R
Created October 17, 2013 17:22
Demo of problem with renderUI and animation slider
library(shiny)
grp <- c(rep("A", 900), rep("B", 1200))
# Define server logic for slider examples
shinyServer(function(input, output) {
sub <- reactive({
grp[grp %in% input$group]
})
This file has been truncated, but you can view the full file.
{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "OBJECTID": 1, "length_ft": 18100, "channel_nu": 1, "SHAPE_Leng": 5608.700802909999766, "up_node": 1, "down_node": 2, "Enabled": 1, "copylength": 5609, "cfslen": 5608.700802909999766, "len": 5.60870080291, "length_mil": 3.48507813464, "x": 652501.4323, "y": 4175026.7346, "km": 5.60870080291 }, "geometry": { "type": "LineString", "coordinates": [ [ -121.261057484636169, 37.68151123762209 ], [ -121.260685407794867, 37.681694369139052 ], [ -121.259601724613617, 37.682157898861817 ], [ -121.258374209915488, 37.68263600359051 ], [ -121.257599684438858, 37.683251570442827 ], [ -121.2571853062869, 37.683826477333028 ], [ -121.25668453071853, 37.684291030838757 ], [ -121.256376837149659, 37.684913480368841 ], [ -121.256303205296916, 37.685395473294669 ], [ -121.25634827630
@hinkelman
hinkelman / channels.csv
Created June 7, 2014 05:03
leaflet-shiny and polyline feature
We can't make this file beautiful and searchable because it's too large.
"long","lat","order","channel_nu"
-121.261057484636,37.6815112376221,1,1
-121.260685407795,37.6816943691391,2,1
-121.259601724614,37.6821578988618,3,1
-121.258374209915,37.6826360035905,4,1
-121.257599684439,37.6832515704428,5,1
-121.257185306287,37.683826477333,6,1
-121.256684530719,37.6842910308388,7,1
-121.25637683715,37.6849134803688,8,1
-121.256303205297,37.6853954732947,9,1
@hinkelman
hinkelman / DSM2Output.csv
Created October 14, 2016 23:36
Introduction to Shiny; example app for BDRUG
We can't make this file beautiful and searchable because it's too large.
"channel","node","vernalis","exports","flow","velocity","x","y"
4,4,1000,0,969.790262132084,0.833772895225137,-121.29817237656,37.72732907252
5,5,1000,0,966.678046818172,0.420142753298407,-121.30444610376,37.75555827741
6,6,1000,0,963.342403924193,0.54710980964832,-121.2996210542,37.77848204796
7,7,1000,0,956.496675449787,0.429192187612527,-121.30954298619,37.79515816156
8,8,1000,0,348.716704417241,0.184562928060122,-121.32714237745,37.80844673355
9,9,1000,0,339.106591970945,0.25899282861556,-121.31236061573,37.82533038655
10,10,1000,0,326.924472117507,0.228500333479895,-121.3218469994,37.84554246538
11,11,1000,0,315.949902308369,0.219456529459077,-121.32691216832,37.8656012755
12,12,1000,0,308.676278379204,0.213770382273699,-121.32890467824,37.89023165523
@hinkelman
hinkelman / NestedForLoop.rkt
Last active March 16, 2019 22:10
Deterministic multistage Beverton-Holt model using nested for loops in Racket
#lang racket/base
;; scalar constants
(define years 30)
(define prop-female 0.5)
(define egg-surv 0.6)
;; age-specific fecundity and survival
(define fecundity #(0 0 200 400 800))
(define survival #(0.2 0.4 0.6 0.8 0))
@hinkelman
hinkelman / NestedForLoop.R
Created February 10, 2019 07:38
Deterministic multistage Beverton-Holt model using nested for loops in R
years = 30
prop_female = 0.5
egg_surv = 0.6
fecundity = c(0, 0, 200, 400, 800)
survival = c(0.2, 0.4, 0.6, 0.8, 0)
capacity = c(1e6, 1e5, 1e4, 1e3, 1e2)
beverton_holt <- function(N, p, c){
N / ((1/p) + (N/c))
@hinkelman
hinkelman / NestedForLoopMatrix.rkt
Created March 17, 2019 22:13
Deterministic multistage Beverton-Holt model using nested for loops and math/array in Racket
#lang racket/base
(require math/array)
;; scalar constants
(define years 30)
(define prop-female 0.5)
(define egg-surv 0.6)
;; age-specific fecundity and survival
#lang typed/racket
(require math)
(provide logmod-typed repeat-logmod-typed)
(: logmod-typed : Integer Flonum Flonum Flonum Flonum -> (Listof Flonum))
(define (logmod-typed t y r k thetasd)
(: calc : Flonum -> Flonum)
@hinkelman
hinkelman / tempconv.rkt
Created May 26, 2019 02:50
Temperature converter
#lang racket/gui
(define (convert-c C)
(number->string (+ 32 (* C (/ 9 5)))))
(define (convert-f F)
(number->string (* (- F 32) (/ 5 9))))
(define (update-fahrenheit control event)
(define tc (send text-celsius get-value))