Skip to content

Instantly share code, notes, and snippets.

View mbedward's full-sized avatar

Michael Bedward mbedward

View GitHub Profile
@richardbeare
richardbeare / smoothing_random_effect.md
Last active July 7, 2023 07:01
ggplot gam smoothing with random effects

Tricks for plotting formant data with gam smoothing

Speech data sets typically contain multiple repetitions of the same speech sound, each sampled at multiple time points. The samples within a given repetition are thus not independent and smoothing procedures should take this into account. One way of doing this with generalized additive models (gams) is via a random effect. However, random effects are not included when performing smoothing with ggplot2 using default options. This gist illustrates some tricks for incuding random effects in ggplot smoothing.

The methods below have been used in the following papers:

#===============================================================================
# 2020-06-19 -- twitter
# improve plot
# Ilya Kashnitsky, ilya.kashnitsky@gmail.com
#===============================================================================
# the challenge
# https://community.storytellingwithdata.com/exercises/one-little-changeand-a-redesign
library(tidyverse)
@gavinsimpson
gavinsimpson / modelled-nuuk-rainfall.png
Last active April 28, 2021 15:43
R code to download, extract, and fit a Tweedie GAM to monthly rainfall total time series from Nuuk, Greenland, using mgcv
modelled-nuuk-rainfall.png
loc = structure(list(country = c("Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Belgium", "Belgium", "Belgium", "Belgium",
"Belgium", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium",
@hrbrmstr
hrbrmstr / countycircles.R
Created September 26, 2014 03:39
County Circles (OK, Ovals) - R version of http://bl.ocks.org/mbostock/4206975
library(rgeos)
library(rgdal) # needs gdal > 1.11.0
library(ggplot2)
# map theme
devtools::source_gist("https://gist.github.com/hrbrmstr/33baa3a79c5cfef0f6df")
# adapted from http://stackoverflow.com/questions/6862742/draw-a-circle-with-ggplot2
# computes a circle from a given diameter. we add "id" so we can have one big
# data frame and group them for plotting
@fancellu
fancellu / TimestampMacro.scala
Created July 22, 2014 09:43
Simple Macro example, allows you to have a string which shows when last compiled. Remember that your main has to be in a different project to the macro (for the moment)
package com.felstar.macros.timestamp
import scala.reflect.macros.blackbox.Context
import scala.language.experimental.macros
object TimestampMacro {
def timestampString: String = macro timestampMacro
def timestampMacro(c: Context): c.Tree = {
import c.universe._
@VladUreche
VladUreche / gist:8396624
Created January 13, 2014 08:39
Scaladoc tutorial for docs.scala-lang.org, in a pitiful state
# Scaladoc Developer Guide
## Introduction
Scaladoc is the tool that enables developers to automatically generate documentation for their Scala (and Java) projects. It is Scala's equivalent of the widely-used Javadoc tool. This means that Javadoc (and even doxygen) users will be familiar with Scaladoc from day 1: for them, it is most beneficial to check out the Scaladoc/Javadoc comparison tables and if necessary, skim through this document to understand specific features.
The rest of this tutorial is aimed at developers new to Scaladoc and other similar tools. It assumes a basic understanding of the Scala language, which is necessary to follow the examples given throughout the tutorial. For the user perspective on the Scaladoc-generated documentation, such as finding a class, understanding the page layout, navigating through diagrams, please refer to the Scaladoc User Guide.
The tutorial will start by a short motivation and then will explain the main concept in Scaladoc: the doc comment.
### Why document?