Skip to content

Instantly share code, notes, and snippets.

View drammock's full-sized avatar

Daniel McCloy drammock

View GitHub Profile
@drammock
drammock / cloudSettings
Last active October 5, 2021 19:11
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-10-05T19:11:12.950Z","extensionVersion":"v3.4.3"}
@drammock
drammock / subscripts-demo.R
Last active March 26, 2019 22:42
demonstrate subscripts in plot labels using phonR's plotVowels()
library(phonR)
data(indoVowels)
mapping <- c(a="eₐ", e="eₑ", i="eᵢ", o="eₒ", u="eᵤ")
indo$label <- mapping[indo$vowel]
png("subscripts-demo.png")
with(indo, plotVowels(f1, f2, vowel, group=gender, plot.tokens=FALSE, plot.means=TRUE, pch.means=label, cex.means=2))
dev.off()
@drammock
drammock / new-mne-flowchart.mmd
Created February 15, 2019 05:45
WIP new flowchart for MNE-Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env Rscript
library(dplyr)
library(ggplot2)
library(ggbeeswarm)
make_dollars <- function(x) paste0('$', prettyNum(x, big.mark=','))
## load data
sal <- read.delim('nih-postdoc-salary.tsv', sep='\t', header=TRUE)
@drammock
drammock / contrast-coding.R
Last active February 13, 2018 18:00
basic examples of R contrast coding for linear models with categorical predictor variables
# 2 levels, treatment contrasts (default)
# here, by luck, our baseline level happens to be alphabetically first, so we get a sensible
# assignment of treatment=1.
foo <- factor(c("treatment", "control"))
contrasts(foo)
# treatment
# control 0
# treatment 1
# 2 levels, sum contrasts (better)
@drammock
drammock / vowel-plot-log-scale-ellipse.R
Last active February 7, 2022 13:52
Regarding ellipses on log-scaled axes
library(phonR)
data(indoVowels)
indo$f1log <- log10(indo$f1)
indo$f2log <- log10(indo$f2)
f1hz <- seq(200, 1200, 100) # chosen based on range(indo$f1)
f2hz <- seq(500, 3500, 500) # chosen based on range(indo$f2)
png("log-scale-ellipses.png")
with(indo, plotVowels(f1log, f2log, vowel, var.col.by=vowel, pretty=TRUE,
@drammock
drammock / bark-scaled-hz-axis-ticks.R
Created October 27, 2017 18:05
plot vowels with tick marks in both equally-spaced bark units, and equally spaced Hz units
library(phonR)
data(indoVowels)
indo$f1bark <- normBark(indo$f1)
indo$f2bark <- normBark(indo$f2)
f1hz <- seq(300, 1200, 300) # chosen based on range(indo$f1)
f2hz <- seq(500, 3500, 500) # chosen based on range(indo$f2)
png("bark-scaled-hz-axis-ticks.png")
with(indo, plotVowels(f1bark, f2bark, vowel, var.col.by=vowel, pretty=TRUE,
@drammock
drammock / plot-mixed-mono-and-diphthongs.R
Last active May 11, 2017 16:52
Demonstration that plotting a mix of monophthongs and diphthongs will work (despite warnings)
library(phonR)
data(indoVowels)
# just one talker, easier to see what's happening on the plot
femaletwo <- subset(indo, subj == "F02")
# simulate offglides, in F1 only (for simplicity)
femaletwo$f1offglide <- femaletwo$f1 + sample(10:50, nrow(femaletwo), replace=TRUE)
femaletwo$f2offglide <- femaletwo$f2
# remove offglides for vowel [a] (for demo purposes)
@drammock
drammock / screenprops.py
Created February 27, 2017 23:45
use expyfun to print the screen size properties
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 27 15:39:08 2017
@author: drmccloy
"""
from __future__ import print_function
from expyfun import ExperimentController

Keybase proof

I hereby claim:

  • I am drammock on github.
  • I am drammock (https://keybase.io/drammock) on keybase.
  • I have a public key ASDyu_iAIY3NIBu85098EybQMaBZiNDk2U3wqUVBExMPCgo

To claim this, I am signing this object: