This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scored_vclass <- function(df,class,vowels, dims = c("F1","F2")){ | |
require(MASS) | |
df <- df[df[ ,class] %in% vowels, ] | |
df[ ,class] <- as.character(df[ ,class]) | |
df[,class] <- as.factor(df[,class]) | |
for(i in dims){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clip.border <- function(deldir.obj, border){ | |
## deldir.obj = output of deldir::deldir | |
## border = list of borders defined in data frames | |
## Importantly, with columns called "x" and "y" | |
require(gpclib) | |
## bord will be a gpc polygon of all of the regions given to the argument "border" | |
bord <- as(matrix(ncol = 2), "gpc.poly") | |
for(i in seq(along = border)){ | |
b <- as(border[[i]], "gpc.poly") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## | |
## Block 1: Preparing the data | |
library(plyr) | |
library(reshape) | |
## Create a Subsystem Column | |
all_philly$Subsystem <- all_philly$VClass | |
levels(all_philly$Subsystem) <- c("Vhr", "Vw", "V", "misc", "Vh", "Vh", "Vhr", "Vw", "Vy", | |
"Vy", "V", "Vy", "Vy", "Vy", "V", "Vw", "Vy", "Vy", "Vhr", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rgdal) #This may be a pain to get installed. The OGR functions come from it. | |
## install gdal, available here: http://www.gdal.org/ | |
## install proj.4, available here: http://trac.osgeo.org/proj/ | |
## For some reason, R wasn't expecting for libproj to be installed where it was, | |
## so I had to tell it to look at /usr/local/bin | |
library(ggplot2) | |
library(reshape2) | |
library(plyr) | |
gpclibPermit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rgdal) #This may be a pain to get installed. The OGR functions come from it. | |
## install gdal, available here: http://www.gdal.org/ | |
## install proj.4, available here: http://trac.osgeo.org/proj/ | |
## For some reason, R wasn't expecting for libproj to be installed where it was, | |
## so I had to tell it to look at /usr/local/bin | |
library(ggplot2) | |
library(reshape2) | |
library(plyr) | |
gpclibPermit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ggplot2 and mgcv for the plot | |
library(ggplot2) | |
library(mgcv) | |
## scales packages to define revlog | |
library(scales) | |
revlog_trans <- function(base = exp(1)){ | |
## Define the desired transformation. | |
trans <- function(x){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{beamer} | |
\usetheme{Singapore} | |
\usepackage{tipa} | |
%% Make the r-code small | |
\ifdefined\knitrout | |
\renewenvironment{knitrout}{\begin{footnotesize}}{\end{footnotesize}} | |
\else | |
\fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(plyr) | |
## Set your effect size, and desired p-value threshold here | |
effect = 0.1 | |
thresh = 0.05 | |
## Sets up the simulation parameters | |
pars = list(mean1 = 1, mean2 = 1+effect, sd1 = 1, sd2 = 1) | |
nsim = 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## You need to model the "failures" | |
psm$Del <- 1-psm$td | |
mod <- glmer(Del ~ Gram2 + (Gram2|Speaker) + (1|Word), data = psm, family = binomial(link = cloglog)) | |
j3 <- exp(fixef(mod)["Gram2semiweak"]) | |
k3 <- exp(fixef(mod)["Gram2mono"]) | |
c(j1, k1) | |
## semiweak mono |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ggplot(Vy, aes(F2, F1, shape = Vowel))+ | |
geom_point()+ | |
theme_bw()+ | |
scale_x_continuous(name = "F2", trans = revlog_trans())+ | |
scale_y_reverse(name = "F1")+ | |
stat_ellipse(level = 0.95)+ | |
opts(legend.position = "none")+ | |
annotate(geom="text", x=2900, y = 460, label = "iyC", size = 5)+ | |
annotate(geom="text", x=2400, y = 750, label = "eyC", size = 5)+ | |
annotate(geom="text", x=1850, y = 970, label = "ay", size = 5) |
OlderNewer