Skip to content

Instantly share code, notes, and snippets.

Avatar

Travis Hinkelman hinkelman

View GitHub Profile
View NetworkGraphApp.R
library(shiny)
library(dplyr)
library(visNetwork)
edges <- readr::read_tsv("https://raw.githubusercontent.com/hinkelman/dataframe/master/network-graph/Edges.tsv",
col_names = FALSE) %>%
setNames(c("from", "to"))
nodes <- readr::read_tsv("https://raw.githubusercontent.com/hinkelman/dataframe/master/network-graph/Nodes.tsv",
col_names = FALSE) %>%
View Program.fs
// Learn more about F# at http://fsharp.org
open MathNet.Numerics.Distributions
[<EntryPoint>]
let main argv =
let yinit = 1.0 // initial population size
let r = 1.4 // maximum population growth rate
let k = 20.0 // carrying capacity
let thetasd = 0.1 // standard deviation for adding noise to the population
@hinkelman
hinkelman / tempconv.rkt
Created May 26, 2019
Temperature converter
View tempconv.rkt
#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))
View stochastic-logistic-typed.rkt
#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 / NestedForLoopMatrix.rkt
Created Mar 17, 2019
Deterministic multistage Beverton-Holt model using nested for loops and math/array in Racket
View NestedForLoopMatrix.rkt
#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
@hinkelman
hinkelman / NestedForLoop.R
Created Feb 10, 2019
Deterministic multistage Beverton-Holt model using nested for loops in R
View NestedForLoop.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 / NestedForLoop.rkt
Last active Mar 16, 2019
Deterministic multistage Beverton-Holt model using nested for loops in Racket
View NestedForLoop.rkt
#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 / DSM2Output.csv
Created Oct 14, 2016
Introduction to Shiny; example app for BDRUG
View DSM2Output.csv
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
@hinkelman
hinkelman / channels.csv
Created Jun 7, 2014
leaflet-shiny and polyline feature
View channels.csv
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
View dsm2-grid
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": [