Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 white_band(img, side): | |
""" | |
Determine best position to crop image | |
Parameters: | |
img (array): Binarised and skew corrected image | |
type (str) : Side of image to crop (top, bottom, center, left or right) | |
Returns: | |
(int): Position on image to crop |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#leave-two-out test + matching | |
# Clear the workspace | |
rm(list = ls()) | |
#load the required libraries | |
#Run the commented code to install the libraries | |
#install.packages("Synth") | |
#install.packages("gtools") |
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(Matching) | |
library(plyr) | |
foo <- read.csv(url("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00089202-1711/daughters.csv")) | |
set.seed(2324) | |
X = cbind(foo$Dems,foo$Repubs , foo$Christian , foo$age, foo$srvlng , foo$demvote, #added 6 more variables | |
foo$Catholic, foo$Protestant, foo$OthParty,foo$OtherC, foo$OtherR, foo$none) | |
Y= foo$nowtot | |
genout <- GenMatch(Tr = foo$treat, X = X, pop.size = 20, nboots=250) |
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
diamond <- read.csv("diamond.csv") #import data | |
member <- c() | |
nonmember <-c() | |
for (x in 1:3) { #iterate over each row | |
member[x] <- diamond$Member.Number.of.purchases[x]/(diamond$Member.Number.of.online.visitors[x]+diamond$Member.Number.of.purchases[x])*100 #percentage of members who bought | |
nonmember[x] <- diamond$Non.Member.Number.of.purchases[x]/(diamond$Non.Member.Number.of.online.visitors[x]+diamond$Non.Member.Number.of.purchases[x])*100 #percentage of nonmembers who made purchases | |
} | |
membership <- rbind(member, nonmember) #creating a table | |
colnames(membership) <- c("31-40","41-50", "51-60") #changing the table head |
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(ggplot2) | |
library(arm) | |
###QUESTION 1### | |
##PART A## | |
#Loading data from the CSV file | |
sesame <- read.csv("https://tinyurl.com/w1g163b") | |
#Splitting the data into two datasets with control and treatment data | |
sesame_treat <- subset(sesame, sesame$treatment == 1) | |
sesame_cont <- subset(sesame, sesame$treatment == 0) |
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
##SETTING UP DATA | |
foo <- read.csv("https://tinyurl.com/yb4phxx8") | |
names(foo) | |
dim(foo) | |
head(foo) | |
date.columns <- c(11,12,14,15,16,17,18,25) | |
for (i in date.columns) { |