Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d456bfa60 | ||
|
|
62fe9d497d | ||
|
|
29a7974941 | ||
|
|
e31ccabf18 | ||
|
|
622fd4db07 | ||
|
|
6aa80534f8 |
@@ -61,10 +61,3 @@ fetch_all <- function(download_dir="inst/records/", create=FALSE) {
|
||||
# if successful, set progressbar to 100%
|
||||
setTimerProgressBar(pb, 250)
|
||||
}
|
||||
|
||||
stop_dir_not_creatable <- function(cond) {
|
||||
# currently this has call: dir.create(download_dir)
|
||||
# do we want to change this to fetch_all(...) ?
|
||||
cond$message <- "Directory does not exist and can't be created. Probably because the path is not writeable."
|
||||
stop(cond)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,13 @@ check_directory <- function(path, create=F) {
|
||||
}
|
||||
}
|
||||
|
||||
stop_dir_not_creatable <- function(cond) {
|
||||
# currently this has call: dir.create(download_dir)
|
||||
# do we want to change this to fetch_all(...) ?
|
||||
cond$message <- "Directory does not exist and can't be created. Probably because the path is not writeable."
|
||||
stop(cond)
|
||||
}
|
||||
|
||||
# appends a file seperator at end of path if needed
|
||||
make_directory_path <- function(path) {
|
||||
if (!str_ends(path, .Platform$file.sep)) str_c(path, .Platform$file.sep)
|
||||
|
||||
@@ -233,6 +233,11 @@ parse_speakerlist <- function(speakerliste_xml) {
|
||||
#'
|
||||
#' @export
|
||||
write_to_csv <- function(tables, path="inst/csv/", create=F) {
|
||||
is_valid_res(tables)
|
||||
stopifnot("path must be of type character" = is.character(path))
|
||||
stopifnot("create must be of type logical" = is.logical(create))
|
||||
|
||||
path <- make_directory_path(path)
|
||||
check_directory(path, create)
|
||||
write.table(tables$speaker, str_c(path, "speaker.csv"))
|
||||
write.table(tables$speeches, str_c(path, "speeches.csv"))
|
||||
@@ -250,6 +255,9 @@ write_to_csv <- function(tables, path="inst/csv/", create=F) {
|
||||
#'
|
||||
#' @export
|
||||
read_from_csv <- function(path="inst/csv/") {
|
||||
stopifnot("path must be of type character" = is.character(path))
|
||||
|
||||
path <- make_directory_path(path)
|
||||
list(speaker = read.table(str_c(path, "speaker.csv")) %>%
|
||||
tibble() %>%
|
||||
mutate(id = as.character(id)),
|
||||
@@ -259,5 +267,7 @@ read_from_csv <- function(path="inst/csv/") {
|
||||
date = as.Date(date)),
|
||||
talks = tibble %$% read.table(str_c(path, "talks.csv")),
|
||||
comments = tibble %$% read.table(str_c(path, "comments.csv")),
|
||||
applause = tibble %$% read.table(str_c(path, "applause.csv")))
|
||||
applause = tibble %$% read.table(str_c(path, "applause.csv"))) -> res
|
||||
is_valid_res(res)
|
||||
res
|
||||
}
|
||||
|
||||
@@ -9,6 +9,26 @@ Using the `remotes` package, this is easily installed via:
|
||||
```r
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
@@ -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}
|
||||
---
|
||||
|
||||
@@ -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}
|
||||
---
|
||||
|
||||
@@ -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}
|
||||
---
|
||||
|
||||
@@ -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}
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user