Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7166d1578 | ||
|
|
896ba1b3b0 | ||
|
|
ecb5677703 | ||
|
|
9d456bfa60 | ||
|
|
62fe9d497d | ||
|
|
29a7974941 | ||
|
|
e31ccabf18 |
@@ -7,6 +7,7 @@ export(join_speaker)
|
||||
export(party_colors)
|
||||
export(read_all)
|
||||
export(read_from_csv)
|
||||
export(read_from_csv_or_fetch)
|
||||
export(repair)
|
||||
export(word_usage_by_date)
|
||||
export(write_to_csv)
|
||||
|
||||
@@ -271,3 +271,22 @@ read_from_csv <- function(path="inst/csv/") {
|
||||
is_valid_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,6 +9,7 @@ Using the `remotes` package, this is easily installed via:
|
||||
```r
|
||||
remotes::install_url("https://git.flavigny.de/christian/hateimparlament/archive/master.zip")
|
||||
```
|
||||
If you want to build the vignettes, pass `build_vignettes = TRUE`.
|
||||
|
||||
# Features
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
title: "explicittopic"
|
||||
title: "Analysis of covered topics"
|
||||
output: rmarkdown::html_vignette
|
||||
vignette: >
|
||||
%\VignetteIndexEntry{explicittopic}
|
||||
%\VignetteIndexEntry{Analysis of covered topics}
|
||||
%\VignetteEngine{knitr::rmarkdown}
|
||||
%\VignetteEncoding{UTF-8}
|
||||
---
|
||||
@@ -34,9 +34,10 @@ read_all("../inst/records/") %>% repair() -> res
|
||||
```
|
||||
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}
|
||||
res <- read_from_csv('../inst/csv/')
|
||||
res <- read_from_csv_or_fetch('../inst/')
|
||||
```
|
||||
|
||||
## Analysis
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
title: "genderequality"
|
||||
title: "Differences in gender"
|
||||
output: rmarkdown::html_vignette
|
||||
vignette: >
|
||||
%\VignetteIndexEntry{genderequality}
|
||||
%\VignetteIndexEntry{Differences in gender}
|
||||
%\VignetteEngine{knitr::rmarkdown}
|
||||
%\VignetteEncoding{UTF-8}
|
||||
---
|
||||
@@ -35,10 +35,13 @@ read_all("../records/") %>% repair() -> res
|
||||
```
|
||||
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}
|
||||
res <- read_from_csv('../inst/csv/')
|
||||
res <- read_from_csv_or_fetch('../inst/')
|
||||
```
|
||||
|
||||
|
||||
and unpack our tibbles
|
||||
```{r}
|
||||
comments <- res$comments
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
title: "generalquestions"
|
||||
title: "General questions"
|
||||
output: rmarkdown::html_vignette
|
||||
vignette: >
|
||||
%\VignetteIndexEntry{generalquestions}
|
||||
%\VignetteIndexEntry{General questions}
|
||||
%\VignetteEngine{knitr::rmarkdown}
|
||||
%\VignetteEncoding{UTF-8}
|
||||
---
|
||||
@@ -34,9 +34,10 @@ read_all("../inst/records/") %>% repair() -> res
|
||||
```
|
||||
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}
|
||||
res <- read_from_csv('../inst/csv/')
|
||||
res <- read_from_csv_or_fetch('../inst/')
|
||||
```
|
||||
|
||||
## Analysis
|
||||
|
||||
@@ -38,9 +38,10 @@ talks <- res$talks
|
||||
We also used `repair` to fix a bunch of formatting issues in the records and unpacked
|
||||
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}
|
||||
tables <- read_from_csv('../inst/csv/')
|
||||
tables <- read_from_csv_or_fetch('../inst/')
|
||||
|
||||
comments <- tables$comments
|
||||
speeches <- tables$speeches
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
title: "interaction"
|
||||
title: "Interaction between fractions"
|
||||
output: rmarkdown::html_vignette
|
||||
vignette: >
|
||||
%\VignetteIndexEntry{interaction}
|
||||
%\VignetteIndexEntry{Interaction between fractions}
|
||||
%\VignetteEngine{knitr::rmarkdown}
|
||||
%\VignetteEncoding{UTF-8}
|
||||
---
|
||||
@@ -34,9 +34,10 @@ read_all("../inst/records/") %>% repair() -> res
|
||||
```
|
||||
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}
|
||||
res <- read_from_csv('../inst/csv/')
|
||||
res <- read_from_csv_or_fetch('../inst/')
|
||||
```
|
||||
|
||||
## Analysis
|
||||
|
||||
Reference in New Issue
Block a user