Skip to content

Instantly share code, notes, and snippets.


Michael Bedward mbedward

View GitHub Profile
mbedward / gist:850fe1923d9b87e3d3c5f9a66fb7e7ca
Created Aug 21, 2018
Model observed proportions as Beta distributed with JAGS
View gist:850fe1923d9b87e3d3c5f9a66fb7e7ca
# Some test data for proportions with mean 0.4
p <- rbeta(20, 4, 6)
# JAGS model
modelTxt <- "model {
for(i in 1:length(p)) {
p[i] ~ dbeta(alpha, beta)
alpha <- mu * phi
beta <- (1-mu) * phi
mbedward / example.R
Created Mar 7, 2017
This function retrieves data for a specified smooth term from a fitted gam object (package mgcv) which is handy when you want to graph the smoother with ggplot.
View example.R
# Toy data set
dat <- data.frame(
x = seq(0, 2*pi, length.out = 100),
y = sin(3*x) / sin(x/2)
# Randomly thin the data
mbedward / convex_hulls.png
Last active Jun 10, 2019
Example of drawing convex hulls around grouped points in R using dplyr and ggplot.
mbedward / gist:6e3dbb232bafec0792ba
Last active Jun 30, 2020
Scala macro to convert between a case class instance and a Map of constructor parameters. Developed by Jonathan Chow (see for description and usage). This version simply updates Jonathan's code to Scala 2.11.2
View gist:6e3dbb232bafec0792ba
import scala.language.experimental.macros
import scala.reflect.macros.blackbox.Context
trait Mappable[T] {
def toMap(t: T): Map[String, Any]
def fromMap(map: Map[String, Any]): T
object Mappable {
mbedward / pom.xml to create GeoTools uber-jar
Created Nov 27, 2013
An example of how to safely combine GeoTools component jars into a single (uber) jar. It uses the Maven shade plugin to properly combine the META-INF/services entries of the individual GeoTools jars.
View pom.xml to create GeoTools uber-jar
<project xmlns="" xmlns:xsi=""
<!-- The version of the GeoTools jars to combine -->
You can’t perform that action at this time.