These are chat archives for krismyu/wintermute

29th
Sep 2014
krismyu
@krismyu
Sep 29 2014 01:05

A markdown plan of action!

  1. Here's a code block
```r
library(ggplot2)
library(lme4)
parse.filename <- function(data, field.filename = "Filename", filename.delim = "-") {
# Extract information from filename
    filename.info <- strsplit(data[,field.filename], filename.delim)

    data$subject <- sapply(filename.info, "[[", 3)
    data$item <- sapply(filename.info, "[[", 5)
    data$rep <- substr(sapply(filename.info, "[[", 6), start = 1, stop = 1)
    data$item.rep <- paste(data$item, data$rep, sep = ".")

    return(data)

}
Test: plotting function code block
```r
```r
```r
```r
```r
oops
plot.f0.arg.ribbon <- function(data = dat.syll.cond, stem = "momoli", param = "pF0", condition = "pos.abs", condition.name = "Position of absolutive", linetype.vals = c("longdash","solid","dotted"), color.vals = c("grey30", "black", "grey30"), annot.pos = 138, median = FALSE, pos.legend = c(0.16, 0.9), limits.y.axis = NULL, limits.x.axis = NULL, syll.markers = TRUE) {

    data.sub <- subset(data, word.stem %in% stem & parameter == param)
    print(unique(data.sub$word.stem))
    # Aggregate by position of absolutive
    dat.agg.cond <- c(condition, "slice.word")

    if (median) { # Call this mean.f0 so I don't have to have a bunch of switches for different cases of variable names
        dat.agg <- ddply(data.sub, dat.agg.cond, summarise, mean.f0 = median(f0, na.rm = TRUE), sd.f0 = sd(f0, na.rm = TRUE), se.f0 = sd(f0, na.rm = TRUE)/sqrt(length(f0)))
        }
    else {
        dat.agg <- ddply(data.sub, dat.agg.cond, summarise, mean.f0 = mean(f0, na.rm = TRUE), sd.f0 = sd(f0, na.rm = TRUE), se.f0 = sd(f0, na.rm = TRUE)/sqrt(length(f0)))
    }

    dat.agg$ymin <- dat.agg$mean.f0 - dat.agg$se.f0
    dat.agg$ymax <- dat.agg$mean.f0 + dat.agg$se.f0

    plot.agg <- ggplot(data = dat.agg, aes_string(x = "slice.word", y = "mean.f0", ymin = "ymin", ymax = "ymax", group = condition, linetype = condition, color = condition)) + geom_ribbon(fill = "grey88", color = NA, alpha = 0.3) + theme_bw() + geom_line(size = 1.5) + geom_point(size = 2)


smo.theme <- theme(panel.grid.major = element_line(size = 0.5, color = "grey"), axis.line = element_line(size = 0.7, color = "black"), legend.position = pos.legend, text = element_text(size = 14), legend.key.width=unit(4,"line"), legend.background = element_rect(size = 1, linetype = "solid", color = "black"), legend.key = element_blank(),axis.title.x = element_text(size = 14), axis.title.y = element_text(size = 14), legend.title = element_text(size = 12), legend.text = element_text(size = 12), axis.text.x = element_text(size = 12), axis.text.y = element_text(size = 12), strip.text = element_text(size = 12)) 

    if (median) {
        scale.y.name <- "Median fundamental frequency (Hz)"
    }
    else {
        scale.y.name <- "Mean fundamental frequency (Hz)"        
    }


    if (is.null(limits.y.axis)) {                        
        plot.agg <- plot.agg + scale_y_continuous(name = scale.y.name, expand = c(0.0, 0.0))
    }

    else{
        plot.agg <- plot.agg + scale_y_continuous(name = scale.y.name, expand = c(0.0, 0.0), limits = limits.y.axis)        
    }

        if (is.null(limits.x.axis)) {                        
        plot.agg <- plot.agg + scale_x_continuous(name = "Time slice in word", breaks = seq(from = 5, to = max(dat.agg$slice.word), by = 5), expand = c(0.0, 0.0))
    }

    else{
        plot.agg <- plot.agg + scale_x_continuous(name = "Time slice in word", breaks = seq(from = 5, to = max(dat.agg$slice.word), by = 5), expand = c(0.0, 0.0), limits = limits.x.axis)
    }

plot.agg.annot <- plot.agg + smo.theme + scale_linetype_manual(name = condition.name, values = linetype.vals) + scale_color_manual(name = condition.name, values = color.vals) 

if(syll.markers) {    
    plot.agg.annot <- plot.agg.annot + geom_vline(xintercept = seq(from = 10, to = max(dat.agg$slice.word) - 10, by = 10), size = 1, color = "grey40") + annotate("text", x = seq(from = 5, to = max(dat.agg$slice.word) - 5, by = 10), y = annot.pos, label = paste("S", 1: (max(dat.agg$slice.word)/10), sep = ""), size = 8)
}

    return(plot.agg.annot)

}
krismyu
@krismyu
Sep 29 2014 01:14
(x2f(x)2dx)(ξ2f^(ξ)2dξ)16π2f24.
eiπ+1=0
poke
Ed Stabler
@epstabler
Sep 29 2014 03:23
no plots?
let rec euclid a = function
   0 -> a
 | b -> euclid b (a mod b)
Ed Stabler
@epstabler
Sep 29 2014 04:00
alt
krismyu
@krismyu
Sep 29 2014 11:25
You could use this for your MG stuff with the UGs. It links to a github repository