This file contains hidden or 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
# Modified from https://martinctc.github.io/blog/vignette-write-and-read-multiple-excel-files-with-purrr/ | |
# Note: this will return numeric codes rather than value labels. Use `as_factor()` to get the latter | |
library(tidyverse) | |
# function for writing the csv files | |
output_csv <- function(data, names){ | |
# output directory | |
folder_path <- "data/" |
This file contains hidden or 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
#!/usr/bin/env python | |
# adopted from https://github.com/derekgreene/twitter-jsonl-tools | |
import argparse | |
import codecs | |
import fileinput | |
import itertools | |
import logging | |
import operator | |
import ujson as json |
This file contains hidden or 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
# -- coding: utf-8 -- | |
# adapted from https://raw.githubusercontent.com/DocNow/twarc/master/twarc/json2csv.py | |
import binascii | |
import csv | |
import codecs | |
import gzip | |
import json |
This file contains hidden or 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
# Method 1 | |
from collections import defaultdict | |
def count_words(string): | |
'''count number of times each word apppears in a string''' | |
counts = defaultdict(int) | |
for word in string.split(): | |
counts[word] += 1 | |
return counts | |
This file contains hidden or 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
# Count values in a dictionary when values are in a list | |
d2 = {'a': ['I','said','that', 'I'],'b': ['she','was','here']} | |
from collections import Counter | |
counts = {k: Counter(v) for k, v in d2.items()} | |
# Count items in sublists | |
lst = [['I', 'said', 'that'], ['said', 'I']] | |
Counter(word for sublist in lst for word in sublist) | |
# Combining the two |
This file contains hidden or 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
#---------------------------------------------------------------------------------------- | |
# File: | |
# Author: Joseph Flanagan, adopted from https://stackoverflow.com/questions/10002021/split-dataframe-into-multiple-output-files-in-r | |
# email: [email protected] | |
# Purpose: Split a dataframe by group, then save each as separate .csv file | |
#---------------------------------------------------------------------------------------- | |
# new tidyverse solution with `group_walk` | |
library(dplyr) | |
library(readr) |
This file contains hidden or 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
#---------------------------------------------------------------------------------------- | |
# File: pvalues-prob-sim.R | |
# Author: Joseph Flanagan, reworking of script by Daniel Lakens | |
# email: [email protected] | |
# Purpose: Function for demonstrating different probability distributions of p-values | |
#---------------------------------------------------------------------------------------- | |
library(pwr) | |
sim_pvalues <- function(n, mean, sd, mu = 100, n_sims = 100000){ |
This file contains hidden or 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
sound = selected ("Sound") | |
textgrid = selected ("TextGrid") | |
spectrogram = selected ("Spectrogram") | |
formant = selected ("Formant") | |
Select inner viewport: 1, 5, 1, 2 | |
select sound | |
Draw... 0 0 0 0 no Curve | |
Draw inner box | |
Select inner viewport: 1, 5, 2, 3.4 | |
select spectrogram |
This file contains hidden or 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
PREFIX dc:<http://purl.org/dc/terms/> | |
PREFIX austalk:<http://ns.austalk.edu.au/> | |
PREFIX olac:<http://www.language-archives.org/OLAC/1.1/> | |
PREFIX ausnc:<http://ns.ausnc.org.au/schemas/ausnc_md_model/> | |
PREFIX foaf:<http://xmlns.com/foaf/0.1/> | |
PREFIX dbpedia:<http://dbpedia.org/ontology/> | |
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> | |
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> | |
PREFIX geo:<http://www.w3.org/2003/01/geo/wgs84_pos#> | |
PREFIX iso639schema:<http://downlode.org/rdf/iso-639/schema#> |
This file contains hidden or 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
#This is my attempt to recreate the [Hack Session for NYTimes Dialect Map Visualization](http://nycdatascience.com/meetup/hack-session-for-nytimes-dialect-map-visualization-sponsored-by-oreilly-strata/) | |
# See question on [stackoverflow](http://stackoverflow.com/questions/29362681/loop-multiple-webpages-in-r) | |
library("RCurl") | |
library("XML") | |
# Get the data |