Skip to content

Instantly share code, notes, and snippets.

View sebastiansauer's full-sized avatar
🇺🇦
🇺🇦

Sebastian Sauer sebastiansauer

🇺🇦
🇺🇦
View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 25 columns, instead of 8. in line 3.
state,area_nr,area_name,total_n,germans_n,foreigner_n,pop_move_n,pop_migr_background_n,income,unemp_n,votes_total,afd_votes,afd_prop,east,state_id,total_n_z,germans_n_z,foreigner_n_z,pop_move_n_z,pop_migr_background_n_z,income_z,unemp_n_z,votes_total_z,afd_votes_z,afd_prop_z
Schleswig-Holstein,1,Flensburg – Schleswig,282800,266700,16100,3478440,28280,20265,20361,170396,11647000,0.06835254348693631,0,15,0.2103609895241015,0.7384953705950867,-0.6866607746103975,-0.23405819513595597,-0.8241784980071718,-0.331229037339419,0.5294325736242255,0.7420571802149715,-0.9559380206641114,-1.0844472782356187
Schleswig-Holstein,2,Nordfriesland – Dithmarschen Nord,232300,219700,12600,3066360,18584,22159,16725,138075,9023000,0.06534854245880861,0,15,-1.12317180392684,-0.9301927624096695,-0.8739260711324136,-0.5246213450924033,-1.1451159729868976,0.4782205523605706,-0.0022599637360526327,-0.8725210301240619,-1.2691398862049443,-1.1394454488402648
Schleswig-Holstein,3,Steinburg – Dithmarschen Süd,220800,209800,11000,2627520,203
@sebastiansauer
sebastiansauer / election.csv
Last active August 31, 2018 05:36
german election data
afd_votes votes_total foreigner_n
11647 170396 16100
9023 138075 12600
11176 130875 11000
11578 156268 9299
10390 150173 25099
11161 130514 13000
15977 186372 26000
17166 191937 18300
11780 137273 9400
@sebastiansauer
sebastiansauer / README.md
Created June 21, 2017 15:12 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@sebastiansauer
sebastiansauer / DiagrammeR_Example.R
Last active June 12, 2017 17:03
Create a graph with DiagrammeR, easy example
# Plot path diagram with {DiagrammeR}
data(Wage, package = "ISLR") #load data
lm_wage <- lm(wage ~ health + age + health:age, data = Wage) # run linear model
summary(lm_wage)
library(semPlot) # plot path diagram with {semPlot}
semPaths(lm_wage, whatLabel = "est", vsize.man = 16, edge.label.cex=0.6)
@sebastiansauer
sebastiansauer / tips_Analyse.R
Created July 19, 2016 08:12
Beispiel-Analyse zum Datensatz "tips"
###############################################################################
### Beispiel-Analyse des Datensatzes "tips"
### von Sebastian Sauer, letztes Update: 2016-01-18
### Zugang zu den Daten: Der Datensatz findet sich im Paket "reshape2"
###############################################################################
# Hinweis: Es ist ganz normal, Syntax/Befehle nachzuschlagen :)
# Eine Möglichkeit dazu ist mit help(Befehl), z.B.
help(library) # oder mit google :)
@sebastiansauer
sebastiansauer / multiple_tabulate.R
Created July 12, 2016 10:12
tabulate multiple columns and plot the frequencies
library(dplyr)
data(Wage, package = "ISLR")
Wage %>%
mutate(wage_f = ntile(wage, 2)) %>% # bin it
group_by(wage_f, health, race) %>%
summarise(count = n()) %>%
ggplot(aes(x = factor(wage_f), y = count, fill = race)) +
geom_bar(stat = "identity") +
@sebastiansauer
sebastiansauer / barplot_with_exact_figures.R
Created June 28, 2016 12:00
Barplot with exact numbers printed in plot
#Barplots with exact numbers
data(tips, package = "reshape2") # load some data
library(dplyr)
library(tidyr)
library(ggplot2)
tips %>%
@sebastiansauer
sebastiansauer / Makefile
Created June 22, 2016 21:41 — forked from lmullen/Makefile
PDF slides and handouts using Pandoc and Beamer
SLIDES := $(patsubst %.md,%.md.slides.pdf,$(wildcard *.md))
HANDOUTS := $(patsubst %.md,%.md.handout.pdf,$(wildcard *.md))
all : $(SLIDES) $(HANDOUTS)
%.md.slides.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -o $@
%.md.handout.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -V handout -o $@
@sebastiansauer
sebastiansauer / normal_distribution_ggplot.R
Created June 22, 2016 21:22
plot normal distribution with ggplot2, simply
# plot normal distribution with ggplot2, simply
library(cowplot)
p1 <- ggplot(data = data.frame(x = c(-3, 3)), aes(x)) +
stat_function(fun = dnorm, n = 101, args = list(mean = 0, sd = 1)) + ylab("") +
scale_y_continuous(breaks = NULL)
p1
@sebastiansauer
sebastiansauer / grade_exam.R
Created May 20, 2016 08:28
This gist provides a convenience function for a typical teacher duty: grade exams.
# Exam grading, as a convenience function for teachers
# Sebastian Sauer
# Stand: 2016-05-20
# need to be installed upfront with "install.packages()"
library(ggplot2)
library(car)
library(tidyr)