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 sys | |
import nltk | |
f = open('students.csv').read() | |
while f.split('\n')[0] != 'name,email': | |
morecsv = raw_input("This does not look like the correct file. Would you like to see more? y/n?") | |
while morecsv != 'y' and 'n': | |
morecsv = raw_input("The prompt was y/n only. Would you like to see more? y/n?") | |
if morecsv == 'y': | |
print f.split('\n')[:10] | |
newcsv = raw_input("Would you like to overwrite this file to create the student list? y/n?") |
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 sys | |
import nltk | |
f = open('students.csv').read() | |
while f.split('\n')[0] != 'name,email': | |
morecsv = raw_input("This does not look like the correct file. Would you like to see more? y/n?") | |
while morecsv != 'y' and 'n': | |
morecsv = raw_input("The prompt was y/n only. Would you like to see more? y/n?") | |
if morecsv == 'y': | |
print f.split('\n')[:10] | |
newcsv = raw_input("Would you like to overwrite this file to create the student list? y/n?") |
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
def fuzzynames(x): | |
fn = [] | |
for key in students.iterkeys(): | |
fn.append(nltk.metrics.edit_distance(x, key)) | |
if any(i > 5 for i in fn): | |
while True: | |
continue = raw_input("%s looks pretty close to %s. Are you sure this is a new student? " % (x,i)) | |
if continue.strip() == 'y' or 'n': | |
break | |
if continue == 'y': |
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
def newstudent(): | |
newname = raw_input("What is the student's name? ") | |
# newname = fuzzynames(newname) | |
if newname == 'quit': | |
return 'Okay! Nevermind.' | |
if newname in students.keys(): | |
addnew = raw_input("%s is already in the list. Are you sure you want to add them again? y/n? " % newname) | |
while addnew != 'y' and addnew!= 'n': | |
addnew = raw_input("This is y/n only. %s is already in the list. Are you sure you want to add them again? y/n? " % newname) | |
if addnew == 'y': |
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
# Load required packages | |
library(reshape2) | |
library(zoo) | |
library(data.table) | |
library(ggplot2) | |
library(lattice) | |
library(foreach) | |
library(doParallel) | |
# Import data and prepare data frames |
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
prep.comp <- function(x){ | |
if (names(x)[1]!='Week'){ | |
stop("The first column should be 'Week'. Check the data.") | |
} | |
x[['Week']] <- as.character(x[['Week']]) | |
x[['weekstart']] <- strsplit(x[['Week']],split=' - ',fixed=TRUE)[[1]] | |
x[['weekend']] <- strsplit(x[['Week']],split=' - ',fixed=TRUE)[[2]] | |
x[['weekstart']] <- as.Date(x[['weekstart']],format='%Y-%m-%d') | |
x[['weekend']] <- as.Date(x[['weekend']],format='%Y-%m-%d') | |
return(x) |
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
setwd("/Users/thiemo/Dropbox/mafundo/") | |
is_installed <- function(mypkg) is.element(mypkg, installed.packages()[,1]) | |
load_or_install<-function(package_names) | |
{ | |
for(package_name in package_names) | |
{ | |
if(!is_installed(package_name)) |
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(foreign) | |
library(dplyr) | |
library(zoo) | |
df1 <- read.dta('~/AeroFS/Googlestuff/searchtechnology-collapsed.dta') | |
df2 <- read.dta('~/AeroFS/Googlestuff/mergedquarterly.dta') | |
load('googledates.rdata') | |
df1 <- left_join(df1,monthlookup,by='time') | |
df1$time <- NULL |
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
prep.comp <- function(x,y){ | |
require(dplyr) | |
if (names(x)[1]!='Week'){ | |
stop("The first column should be 'Week'. Check the data.") | |
} | |
countryname <- names(x)[2] | |
x[['Week']] <- as.character(x[['Week']]) | |
x[['weekstart']] <- substr(x[['Week']],1,11) | |
x[['weekend']] <- substr(x[['Week']],13,24) | |
x[['weekstart']] <- as.Date(x[['weekstart']],format='%Y-%m-%d') |
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
# Create function to get data from weekly to monthly | |
weekly.monthly <- function(x){ | |
require(dplyr) | |
if (names(x)[1]!='Week'){ | |
stop("The first column should be 'Week'. Check the data.") | |
} | |
countryname <- names(x)[2] | |
x[['Week']] <- as.character(x[['Week']]) | |
x[['weekstart']] <- substr(x[['Week']],1,11) | |
x[['weekend']] <- substr(x[['Week']],13,24) |