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
library(shiny) | |
library(shinyjs) | |
# Get table metadata. For now, just the fields | |
# Further development: also define field types | |
# and create inputs generically | |
GetTableMetadata <- function() { | |
fields <- c(id = "Id", |
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
# Archigos transitions and tenure by regime type | |
# | |
# Andreas Beger | |
# 15 December 2014 | |
setwd("~/Desktop/archigos-polity") | |
library(foreign) | |
library(gdata) |
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
#' @title PRESS | |
#' @author Thomas Hopper | |
#' @description Returns the PRESS statistic (predictive residual sum of squares). | |
#' Useful for evaluating predictive power of regression models. | |
#' @param linear.model A linear regression model (class 'lm'). Required. | |
#' | |
PRESS <- function(linear.model) { | |
#' calculate the predictive residuals | |
pr <- residuals(linear.model)/(1-lm.influence(linear.model)$hat) | |
#' calculate the PRESS |
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
function table2CSV(table, delim){ | |
var csv = "data:application/csv;charset=utf-8,"; | |
if(table instanceof HTMLElement){ | |
table = $(table); | |
} | |
if(table instanceof jQuery){ | |
var regex = /,/g; | |
if(delim){ | |
regex = new RegExp(delim, 'g'); | |
delim = encodeURIComponent(delim); |
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
/* | |
You can create a spinner using either of the variants below: | |
$("#el").spin(true); //Starts the spinner. | |
$("#el").spin(false); // Kills the spinner. | |
*/ | |
(function($) { | |
$.fn.spin = function(opts) { |
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
variable | Question | |
---|---|---|
cowcode | Correlates of War country code (www.correlatesofwar.org). | |
country | Country name. | |
systyear | Year in which the constitutional system was promulgated. | |
systid | Unique identification number for the constitutional system. | |
evntyear | Year of promulgation of the most recent constitutional event. | |
endyear | Year through which the data for the event is guaranteed valid. | |
evntid | Unique identification number for the constitutional event. | |
evnttype | Event type (e.g. amendment, new, etc.). | |
source | What is the source for the text of the Constitution? |
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
getPackage <- function(pkg){ | |
if(!require(pkg, character.only=TRUE)){ | |
install.packages(pkg, dependencies=TRUE) | |
library(pkg, character.only=TRUE) | |
} | |
return(TRUE) | |
} | |
getPackages <- function(pkgs){ | |
for (pkg in pkgs){ |
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
import nltk, glob | |
for filename in glob.glob( '*.htm*' ): | |
filein = open(filename) | |
html = filein.read() | |
raw = nltk.clean_html(html) | |
fileout = open(filename.rstrip('.html')+'.txt', 'w+') | |
fileout.write(raw) |
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
<?php | |
class makeExt{ | |
protected $project = "<project>"; | |
protected $name = "<you>"; | |
protected $desc = "<insert a short description here>"; | |
public function __construct(){ | |
global $argv, $argc; |
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 | |
# encoding: utf-8 | |
import smtplib | |
from datetime import datetime | |
def noticeEMail(starttime, usr, psw, fromaddr, toaddr): | |
""" | |
Sends an email message through GMail once the script is completed. |
NewerOlder