Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7166d1578 | ||
|
|
896ba1b3b0 | ||
|
|
ecb5677703 |
@@ -7,6 +7,7 @@ export(join_speaker)
|
|||||||
export(party_colors)
|
export(party_colors)
|
||||||
export(read_all)
|
export(read_all)
|
||||||
export(read_from_csv)
|
export(read_from_csv)
|
||||||
|
export(read_from_csv_or_fetch)
|
||||||
export(repair)
|
export(repair)
|
||||||
export(word_usage_by_date)
|
export(word_usage_by_date)
|
||||||
export(write_to_csv)
|
export(write_to_csv)
|
||||||
|
|||||||
@@ -271,3 +271,22 @@ read_from_csv <- function(path="inst/csv/") {
|
|||||||
is_valid_res(res)
|
is_valid_res(res)
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' @param path directory of csv files to read
|
||||||
|
#' read data from csv files if they exist already
|
||||||
|
#' otherwise fetch protocols and then write the data into csv files
|
||||||
|
#'
|
||||||
|
#' @export
|
||||||
|
read_from_csv_or_fetch <- function(path="inst/") {
|
||||||
|
path <- make_directory_path(path)
|
||||||
|
res <- tryCatch(read_from_csv(str_c(path, "csv/")),
|
||||||
|
error = function(c) NULL)
|
||||||
|
if (!is.null(res)) return(res)
|
||||||
|
|
||||||
|
fetch_all(str_c(path, "records/"), create=T)
|
||||||
|
read_all(str_c(path, "records/")) %>%
|
||||||
|
repair() ->
|
||||||
|
res
|
||||||
|
write_to_csv(res, str_c(path, "csv/"), create=T)
|
||||||
|
res
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,26 +9,7 @@ Using the `remotes` package, this is easily installed via:
|
|||||||
```r
|
```r
|
||||||
remotes::install_url("https://git.flavigny.de/christian/hateimparlament/archive/master.zip")
|
remotes::install_url("https://git.flavigny.de/christian/hateimparlament/archive/master.zip")
|
||||||
```
|
```
|
||||||
Since the fetching and reading is very slow and depends on an internet connection, all vignettes
|
If you want to build the vignettes, pass `build_vignettes = TRUE`.
|
||||||
use `read_from_csv` to read already parsed tibbles from `.csv` files.
|
|
||||||
|
|
||||||
That's why, if you want to build the vignettes yourself, you need to
|
|
||||||
download the source code, e.g. on Linux
|
|
||||||
```
|
|
||||||
git clone https://git.flavigny.de/christian/hateimparlament
|
|
||||||
cd hateimparlament
|
|
||||||
```
|
|
||||||
then start `R` and do
|
|
||||||
```r
|
|
||||||
devtools::load_all()
|
|
||||||
fetch_all(create = TRUE)
|
|
||||||
read_all() %>% repair() -> res
|
|
||||||
write_to_csv(res, create = TRUE)
|
|
||||||
```
|
|
||||||
Then finally, do:
|
|
||||||
```r
|
|
||||||
devtools::install(build_vignettes = TRUE)
|
|
||||||
```
|
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -1,28 +1,16 @@
|
|||||||
\documentclass{article}
|
\documentclass{article}
|
||||||
\usepackage[ngerman]{babel}
|
|
||||||
\usepackage[top=2.5cm, bottom=2.5cm]{geometry}
|
\usepackage[top=2.5cm, bottom=2.5cm]{geometry}
|
||||||
\title{Abschlussbericht}
|
|
||||||
\author{Leon Burgard, Josua Kugler, Christian Merten}
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\maketitle
|
|
||||||
\section*{Projektbeschreibung}
|
\section*{Projektbeschreibung}
|
||||||
Unser Projekt \glqq Plenarprotokolle \grqq stellt mittels dem Paket \verb|hateimparlament| Funktionen zur Analyse der Plenarprotokolle der 19. Wahlperiode des deutschen Bundestages zur Verfügung. Diese Funktionen können in vier Bereiche unterteilt werden:
|
Wir haben zunächst die Plenarprotokolle der 19. Wahlperiode von der Website automatisiert herunterladen lassen.
|
||||||
\begin{enumerate}
|
Als nächstes haben wir die Daten in ein für die Analyse sinnvolles Format gebracht, d.h. 5 Tibbles und Fehler ausgebessert.
|
||||||
\item Herunterladen der Protokolle
|
Daraufhin konnten wir mit der Analyse beginnen.
|
||||||
\item Konvertierung der XML-Dateien in Tibbles
|
Insbesondere
|
||||||
\item Reparieren von Fehlern
|
\section*{Werkzeuge aus der Vorlesung}
|
||||||
\item Analyse
|
Wir haben, da es hauptsächlich um Datenanalyse ging, sehr viel mit tidyverse gearbeitet.
|
||||||
\end{enumerate}
|
Ganz zu Beginn haben wir fürs fetchen der Protokolle rvest verwendet.
|
||||||
Das Herunterladen der Protokolle gelingt über die Funktion
|
Für die Visualisierung haben wir ggplot2 sowie vignettes genutzt.
|
||||||
\verb|fetch_all()|, welche auf die Website des deutschen Bundestages zugreift und die XML-Dateien einzeln herunterlädt. Hierzu haben wir das Paket rvest verwendet, welches wir bereits in der Vorlesung kennengelernt haben.
|
|
||||||
Durch \verb|read_all()| werden diese heruntergeladenen XML-Dateien in eine benannte Liste mit fünf Tibbles (speaker, speeches, talks, comments und applause) geschrieben. Allerdings benötigt man diese Tibbles immer wieder und es ist ziemlich zeitaufwändig die XML-Dateien immer wieder neu in Tibbles einzulesen, deshalb haben wir zusätzlich eine Funkion \verb|write_to_csv()| geschrieben, die die fertigen Tibbles als CSV-Dateien speichert. Diese können dann sehr schnell durch \verb|read_from_csv()| eingelesen werden, wodurch viel Zeit gesparrt wird.
|
|
||||||
Da diese Protokolle kleine Fehler enthalten, müssen diese noch im nächsten Schritt bereinigt werden, was mit \verb|repair()| funktioniert. Hierbei wird das Paket tidyverse viel benutzt, welches insgesamt sehr viel in unserem Projekt beansprucht wird, da wir uns mit der Datenanalyse beschäftigen.
|
|
||||||
In \verb|analyse.R| stellen wir noch einige Hilfsfunktionen bereit, die es dem Nutzer vereinfachen die Daten auszuwerten. Beispielsweise steht schon eine Funktion zur Verfügung, die ein Balkendiagramm erstellt, bei dem jede Partei des Bundestages sperat ausgewertet wird. Hierbei wird das Paket \verb|ggplot2| verwendet.
|
|
||||||
Im letzten Schritt unseres Projekts haben wir Fragestellungen festgelegt, die wir mithilfe von unserem Paket beantworten wollten. Die Daten und unsere Ergebnisse visualisierten wir mithilfe von \verb|ggplot2| und \verb|tidyverse| in Vignetten.
|
|
||||||
\section*{Organisation des Teams}
|
\section*{Organisation des Teams}
|
||||||
Während der ersten Projektphase wurden hauptsächlich die Funktionen zum Herunterladen der Dateien und Konvertieren und Reparieren der Tibbles geschrieben. Dies geschah größtenteils in Einzelarbeit, wobei hierbei die gegenseitige Kontrolle und Nachfragen die Funktionen optimiert haben. Zwischendurch wurde immer mal wieder zu einer HeiConf-Konferenz einberufen, um sich selbst den Zwischenstand klar zu machen und die Herausforderungen für die nächsten Wochen zu besprechen.
|
|
||||||
In der zweiten Hälfte des Projekts kümmerten wir uns dann um die Analyse der Daten und stellten unsere Ergebnisse in Vignetten da und erzeugten Dokumentationen für alle Funktionen, die für den Nutzer wichtig sind.
|
|
||||||
\newpage
|
|
||||||
\section*{Meine Beteiligung}
|
\section*{Meine Beteiligung}
|
||||||
\input{meine_beteiligung.tex}
|
|
||||||
\end{document}
|
\end{document}
|
||||||
@@ -34,9 +34,10 @@ read_all("../inst/records/") %>% repair() -> res
|
|||||||
```
|
```
|
||||||
We also used `repair` to fix a bunch of formatting issues in the records.
|
We also used `repair` to fix a bunch of formatting issues in the records.
|
||||||
|
|
||||||
For development purposes, we load the tables from csv files.
|
For development purposes, we only fetch records if they are not already
|
||||||
|
stored as csv files:
|
||||||
```{r}
|
```{r}
|
||||||
res <- read_from_csv('../inst/csv/')
|
res <- read_from_csv_or_fetch('../inst/')
|
||||||
```
|
```
|
||||||
|
|
||||||
## Analysis
|
## Analysis
|
||||||
|
|||||||
@@ -35,10 +35,13 @@ read_all("../records/") %>% repair() -> res
|
|||||||
```
|
```
|
||||||
We also used `repair` to fix a bunch of formatting issues in the records.
|
We also used `repair` to fix a bunch of formatting issues in the records.
|
||||||
|
|
||||||
For development purposes, we load the tables from csv files.
|
For development purposes, we only fetch records if they are not already
|
||||||
|
stored as csv files:
|
||||||
```{r}
|
```{r}
|
||||||
res <- read_from_csv('../inst/csv/')
|
res <- read_from_csv_or_fetch('../inst/')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
and unpack our tibbles
|
and unpack our tibbles
|
||||||
```{r}
|
```{r}
|
||||||
comments <- res$comments
|
comments <- res$comments
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ read_all("../inst/records/") %>% repair() -> res
|
|||||||
```
|
```
|
||||||
We also used `repair` to fix a bunch of formatting issues in the records.
|
We also used `repair` to fix a bunch of formatting issues in the records.
|
||||||
|
|
||||||
For development purposes, we load the tables from csv files.
|
For development purposes, we only fetch records if they are not already
|
||||||
|
stored as csv files:
|
||||||
```{r}
|
```{r}
|
||||||
res <- read_from_csv('../inst/csv/')
|
res <- read_from_csv_or_fetch('../inst/')
|
||||||
```
|
```
|
||||||
|
|
||||||
## Analysis
|
## Analysis
|
||||||
|
|||||||
@@ -38,9 +38,10 @@ talks <- res$talks
|
|||||||
We also used `repair` to fix a bunch of formatting issues in the records and unpacked
|
We also used `repair` to fix a bunch of formatting issues in the records and unpacked
|
||||||
the result into more descriptive variables.
|
the result into more descriptive variables.
|
||||||
|
|
||||||
For development purposes, we load the tables from csv files.
|
For development purposes, we only fetch records if they are not already
|
||||||
|
stored as csv files:
|
||||||
```{r}
|
```{r}
|
||||||
tables <- read_from_csv('../inst/csv/')
|
tables <- read_from_csv_or_fetch('../inst/')
|
||||||
|
|
||||||
comments <- tables$comments
|
comments <- tables$comments
|
||||||
speeches <- tables$speeches
|
speeches <- tables$speeches
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ read_all("../inst/records/") %>% repair() -> res
|
|||||||
```
|
```
|
||||||
We also used `repair` to fix a bunch of formatting issues in the records.
|
We also used `repair` to fix a bunch of formatting issues in the records.
|
||||||
|
|
||||||
For development purposes, we load the tables from csv files.
|
For development purposes, we only fetch records if they are not already
|
||||||
|
stored as csv files:
|
||||||
```{r}
|
```{r}
|
||||||
res <- read_from_csv('../inst/csv/')
|
res <- read_from_csv_or_fetch('../inst/')
|
||||||
```
|
```
|
||||||
|
|
||||||
## Analysis
|
## Analysis
|
||||||
|
|||||||
Reference in New Issue
Block a user