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(XML) | |
#use R's inbuilt unzip function, knowing that the required metadata is in docProps/core.xml | |
doc = xmlInternalTreeParse(unzip('test.docx','docProps/core.xml')) | |
#define the namespace | |
ns=c('dc'= 'http://purl.org/dc/elements/1.1/') | |
#extract the author using xpath query | |
author = xmlValue(getNodeSet(doc, '/*/dc:creator', namespaces=ns)[[1]]) |
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
# McCrae's rpa (r profile agreement) | |
rpa <- function(p1,p2){ | |
if (length(p1) != length(p2)) | |
stop("'p1' and 'p2' must have the same length") | |
k <- length(p1) | |
sumM.sq <- sum(((p1 + p2)/2)^2) | |
sumd.sq <- sum((p1 - p2)^2) | |
ipa <- (k + 2*sumM.sq - sumd.sq) / sqrt(10*k) | |
rpa <- ipa / sqrt(k - 2 + ipa^2) | |
return(rpa) |
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
read.gspreadsheet <- function(key) { | |
require(RCurl) | |
myCsv <- getURL(paste("https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=", | |
key, "&single=true&gid=0&output=csv", sep = ""), | |
.encoding = "UTF8") | |
read.table(textConnection(myCsv), header = T, sep = ",", stringsAsFactors = FALSE) | |
} |
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
# Install dependencies | |
#install.packages(c("fftw","tuneR","rgl","rpanel", "seewave"), repos="http://cran.at.r-project.org/") | |
# for Fast Fourier transform (fftw) to work, install | |
# the fftw lib (e.g. brew install fftw) | |
# Load libraries | |
library(data.table) | |
library(tuneR) | |
library(seewave) |
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
# A function for transliteration inspired by https://gist.github.com/tukachev/7550665 but way too faster | |
translit2 <- function(text){ | |
transliterations <- data.frame( | |
lat = c("A","B","V","G","D","E","YO","ZH","Z","I","J","K","L","M","N", | |
"O","P","R","S","T","U","F","KH","C","CH","SH","SHCH","''","Y","'","E'","YU","YA", | |
"a","b","v","g","d","e","yo","zh","z","i","j","k","l","m","n","o","p","r", | |
"s","t","u","f","kh","c","ch","sh","shch","''","y","'","e'","yu","ya"), | |
rus = c("А","Б","В","Г","Д","Е","Ё","Ж","З","И","Й","К","Л","М","Н","О","П", | |
"Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я", |