# EU Election 2019

## Parties of Austria

https://www.bmi.gv.at/412/Europawahlen/Europawahl_2019/start.aspx#pk_04

```{r}
europa <- read.table("europa.txt", sep="\t", header=TRUE)
fpoe <- read.table("fpoe.txt", sep="\t", header=TRUE)
gruene <- read.table("gruene.txt", sep="\t", header=TRUE)
kpoe <- read.table("kpoe.txt", sep="\t", header=TRUE)
neos <- read.table("neos.txt", sep="\t", header=TRUE, quote="\"")
oevp <- read.table("oevp.txt", sep="\t", header=TRUE)
spoe <- read.table("spoe.txt", sep="\t", header=TRUE)

eu2019.color <- c("#d7d7d7", "#0056A2", "#88B626", "#f3e500", "#e84188", "#63C3D0", "#ce000c")
eu2019.party <- c("EUROPA", "FPÖ", "Grüne", "KPÖ", "NEOS", "ÖVP", "SPÖ")
```

## avg age

```{r}
europa.avg  <- 2019 - mean(europa$Geb..Jahr)
fpoe.avg    <- 2019 - mean(fpoe$Geb..Jahr)
gruene.avg  <- 2019 - mean(gruene$Geb..Jahr)
kpoe.avg    <- 2019 - mean(kpoe$Geb..Jahr)
neos.avg    <- 2019 - mean(neos$Geb..Jahr)
oevp.avg    <- 2019 - mean(oevp$Geb..Jahr)
spoe.avg    <- 2019 - mean(spoe$Geb..Jahr)

eu2019.avgages <- c(europa.avg, fpoe.avg, gruene.avg, kpoe.avg, neos.avg, oevp.avg, spoe.avg)

x <- barplot(eu2019.avgages, ylim = c(0, 65), names.arg = eu2019.party, main="avg age", col=eu2019.color, ylab = "age", xlab ="party")
y <- as.matrix(eu2019.avgages) + 4
text(x, y, labels = as.integer(eu2019.avgages))
```

## all those titles

```{r}
europa.titles  <- length(europa$Titel[europa$Titel != ""]) / length(europa$Titel) * 100
fpoe.titles    <- length(fpoe$Titel[fpoe$Titel != ""])     / length(fpoe$Titel)   * 100
gruene.titles  <- length(gruene$Titel[gruene$Titel != ""]) / length(gruene$Titel) * 100
kpoe.titles    <- length(kpoe$Titel[kpoe$Titel != ""])     / length(kpoe$Titel)   * 100
neos.titles    <- length(neos$Titel[neos$Titel != ""])     / length(neos$Titel)   * 100
oevp.titles    <- length(oevp$Titel[oevp$Titel != ""])     / length(oevp$Titel)   * 100
spoe.titles    <- length(spoe$Titel[spoe$Titel != ""])     / length(spoe$Titel)   * 100

eu2019.titles <- c(europa.titles, fpoe.titles, gruene.titles, kpoe.titles, neos.titles, oevp.titles, spoe.titles)

x <- barplot(eu2019.titles, names.arg = eu2019.party, ylim = c(0, 100), main="academic titles", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.titles) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.titles))
```

## avg name length

```{r}
europa.avgchars  <- mean(nchar(paste(europa$Vorname, europa$Familienname, sep = " ")))
fpoe.avgchars    <- mean(nchar(paste(fpoe$Vorname, fpoe$Familienname, sep = " ")))
gruene.avgchars  <- mean(nchar(paste(gruene$Vorname, gruene$Familienname, sep = " ")))
kpoe.avgchars    <- mean(nchar(paste(kpoe$Vorname, kpoe$Familienname, sep = " ")))
neos.avgchars    <- mean(nchar(paste(neos$Vorname, neos$Familienname, sep = " ")))
oevp.avgchars    <- mean(nchar(paste(oevp$Vorname, oevp$Familienname, sep = " ")))
spoe.avgchars    <- mean(nchar(paste(spoe$Vorname, spoe$Familienname, sep = " ")))

eu2019.avgchars <- c(europa.avgchars, fpoe.avgchars, gruene.avgchars, kpoe.avgchars, neos.avgchars, oevp.avgchars, spoe.avgchars)

x <- barplot(eu2019.avgchars, names.arg = eu2019.party, ylim=c(0, 25), main="avg name length", col=eu2019.color, ylab = "length", xlab ="party")
y <- as.matrix(eu2019.avgchars) + 4
text(x, y, labels = as.integer(eu2019.avgchars))
```

## studis

```{r}
percentageOfStudents <- function(jobs) {
  s <- length(grep("Student*", jobs))
  j <- length(jobs)
  return(s/j*100)
}

europa.studs  <- percentageOfStudents(europa$Beruf)
fpoe.studs    <- percentageOfStudents(fpoe$Beruf)
gruene.studs  <- percentageOfStudents(gruene$Beruf)
kpoe.studs    <- percentageOfStudents(kpoe$Beruf)
neos.studs    <- percentageOfStudents(neos$Beruf)
oevp.studs    <- percentageOfStudents(oevp$Beruf)
spoe.studs    <- percentageOfStudents(spoe$Beruf)

eu2019.studs <- c(europa.studs, fpoe.studs, gruene.studs, kpoe.studs, neos.studs, oevp.studs, spoe.studs)

x <- barplot(eu2019.studs, names.arg = eu2019.party, ylim=c(0, 100), main="students", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.studs) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.studs))
```

## it girls & guys

```{r}
percentageOfitgng <- function(jobs) {
  s <- length(grep("Programmierer*|IT*|Informatik*|System*|EDV*|Software*", jobs))
  j <- length(jobs)
  return(s/j*100)
}

europa.itgng  <- percentageOfitgng(europa$Beruf)
fpoe.itgng    <- percentageOfitgng(fpoe$Beruf)
gruene.itgng  <- percentageOfitgng(gruene$Beruf)
kpoe.itgng    <- percentageOfitgng(kpoe$Beruf)
neos.itgng    <- percentageOfitgng(neos$Beruf)
oevp.itgng    <- percentageOfitgng(oevp$Beruf)
spoe.itgng    <- percentageOfitgng(spoe$Beruf)

eu2019.itgng <- c(europa.itgng, fpoe.itgng, gruene.itgng, kpoe.itgng, neos.itgng, oevp.itgng, spoe.itgng)

x <- barplot(eu2019.itgng, names.arg = eu2019.party, ylim=c(0, 100), main="IT girls n guys", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.itgng) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.itgng))
```

## KiwaraRinnen

```{r}
percentageOfKiwaraRinnen <- function(jobs) {
  s <- length(grep("Polizist*", jobs))
  j <- length(jobs)
  return(s/j*100)
}

eu2019.kiwararinnen <- c(
    percentageOfKiwaraRinnen(europa$Beruf),
    percentageOfKiwaraRinnen(fpoe$Beruf),
    percentageOfKiwaraRinnen(gruene$Beruf),
    percentageOfKiwaraRinnen(kpoe$Beruf),
    percentageOfKiwaraRinnen(neos$Beruf),
    percentageOfKiwaraRinnen(oevp$Beruf),
    percentageOfKiwaraRinnen(spoe$Beruf)
)

x <- barplot(eu2019.kiwararinnen, names.arg = eu2019.party, ylim=c(0, 100), main="KiwaraRinnen", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.kiwararinnen) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.kiwararinnen))
```

## teachrs

```{r}
percentageOfTeachers <- function(jobs) {
  s <- length(grep("Lehrer*|Professor*", jobs))
  j <- length(jobs)
  return(s/j*100)
}

eu2019.teachers <- c(
    percentageOfTeachers(europa$Beruf),
    percentageOfTeachers(fpoe$Beruf),
    percentageOfTeachers(gruene$Beruf),
    percentageOfTeachers(kpoe$Beruf),
    percentageOfTeachers(neos$Beruf),
    percentageOfTeachers(oevp$Beruf),
    percentageOfTeachers(spoe$Beruf)
)

x <- barplot(eu2019.teachers, names.arg = eu2019.party, ylim=c(0, 100), main="teachrs", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.teachers) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.teachers))
```

## retired girls n guys

```{r}
percentageOfRetiredPeople <- function(jobs) {
  s <- length(grep("Pension*", jobs))
  j <- length(jobs)
  return(s/j*100)
}

eu2019.retired <- c(
    percentageOfRetiredPeople(europa$Beruf),
    percentageOfRetiredPeople(fpoe$Beruf),
    percentageOfRetiredPeople(gruene$Beruf),
    percentageOfRetiredPeople(kpoe$Beruf),
    percentageOfRetiredPeople(neos$Beruf),
    percentageOfRetiredPeople(oevp$Beruf),
    percentageOfRetiredPeople(spoe$Beruf)
)

x <- barplot(eu2019.retired, names.arg = eu2019.party, ylim=c(0, 100), main="retired", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.retired) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.retired))
```

## farmer

```{r}
percentageOfFarmer <- function(jobs) {
  s <- length(grep("*bauer*|Landwirt*", jobs))
  j <- length(jobs)
  return(s/j*100)
}

eu2019.farmer <- c(
    percentageOfFarmer(europa$Beruf),
    percentageOfFarmer(fpoe$Beruf),
    percentageOfFarmer(gruene$Beruf),
    percentageOfFarmer(kpoe$Beruf),
    percentageOfFarmer(neos$Beruf),
    percentageOfFarmer(oevp$Beruf),
    percentageOfFarmer(spoe$Beruf)
)

x <- barplot(eu2019.farmer, names.arg = eu2019.party, ylim=c(0, 100), main="farmer", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.farmer) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.farmer))
```

## consultants

```{r}
percentageOfConsultants <- function(jobs) {
  s <- length(grep("*consultant*|*Consultant*", jobs))
  j <- length(jobs)
  return(s/j*100)
}

eu2019.consultants <- c(
    percentageOfConsultants(europa$Beruf),
    percentageOfConsultants(fpoe$Beruf),
    percentageOfConsultants(gruene$Beruf),
    percentageOfConsultants(kpoe$Beruf),
    percentageOfConsultants(neos$Beruf),
    percentageOfConsultants(oevp$Beruf),
    percentageOfConsultants(spoe$Beruf)
)

x <- barplot(eu2019.consultants, names.arg = eu2019.party, ylim=c(0, 100), main="consultant", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.consultants) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.consultants))
```

## from vienna

```{r}
percentageOfVie <- function(places) {
  s <- length(grep("Wien", places))
  j <- length(places)
  return(s/j*100)
}

eu2019.wiener <- c(
    percentageOfVie(europa$Ort),
    percentageOfVie(fpoe$Ort),
    percentageOfVie(gruene$Ort),
    percentageOfVie(kpoe$Ort),
    percentageOfVie(neos$Ort),
    percentageOfVie(oevp$Ort),
    percentageOfVie(spoe$Ort)
)

x <- barplot(eu2019.wiener, names.arg = eu2019.party, ylim=c(0, 100), main="from vienna", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.wiener) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.wiener))
```

## bgld

```{r}
percentageOfBgld <- function(zipcodes) {
  s <- length(zipcodes[startsWith(as.character(zipcodes), "7")])
  j <- length(zipcodes)
  return(s/j*100)
}

eu2019.bgld <- c(
    percentageOfBgld(europa$PLZ),
    percentageOfBgld(fpoe$PLZ),
    percentageOfBgld(gruene$PLZ),
    percentageOfBgld(kpoe$PLZ),
    percentageOfBgld(neos$PLZ),
    percentageOfBgld(oevp$PLZ),
    percentageOfBgld(spoe$PLZ)
)

x <- barplot(eu2019.bgld, names.arg = eu2019.party, ylim=c(0, 100), main="from bgld", col=eu2019.color, ylab = "% of ppl", xlab ="party")
y <- as.matrix(eu2019.bgld) + 4
text(x, y, labels = sprintf("%1.2f%%", eu2019.bgld))
```