Skip to content

Instantly share code, notes, and snippets.

View EoinTravers's full-sized avatar

Eoin Travers EoinTravers

View GitHub Profile
@EoinTravers
EoinTravers / bibtexSort.py
Last active August 29, 2015 14:13
Manually sorts bracketed BibTex citations in Pandoc Markdown
#!/usr/bin/env python
# Manually sorts bracketed BibTex citations in Pandoc Markdown.
# pandoc-citeproc will do with automatically for most csl styles,
# but has no option to override the sorting order for specific
# groups of references - for example if you wish to say
# "Smith's (1997; 2001; Aardvark & Smith, 1990) work with ant colonies ..."
# References are sorted by author, then by year, then by title,
# as per the APA system.
library(lme4)
library(lmerTest)
library(dplyr)
data = read.table('~/Desktop/sof_data.csv')
# or
#data = read.table('clipboard')
# Analysing all data
# t test

This is a pretty ugly hack, and I apologize to everyone concerned, but I've got around this problem like so:

grouped = data.groupby(['code', 'acc'])
means = grouped.mean()
means['nx'] = [group.nx.mean() for name, group in grouped]
means['ny'] = [group.ny.mean() for name, group in grouped]

group1_correct = means.xs('group1').xs(True)
group1_correct['nx'] # Can only be indexed this way
@EoinTravers
EoinTravers / html_toggle
Created December 4, 2013 11:53
html_toggle template for ipython nbconvert
{%- extends 'html_basic.tpl' -%}
{%- block header -%}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>{{resources['metadata']['name']}}</title>