Selaa lähdekoodia

add bare read_from_csv_or_fetch

alternative-vignettes
flavis 4 vuotta sitten
vanhempi
commit
ecb5677703
7 muutettua tiedostoa jossa 33 lisäystä ja 10 poistoa
  1. +1
    -0
      NAMESPACE
  2. +15
    -0
      R/parse.R
  3. +3
    -2
      vignettes/explicittopic.Rmd
  4. +5
    -2
      vignettes/genderequality.Rmd
  5. +3
    -2
      vignettes/generalquestions.Rmd
  6. +3
    -2
      vignettes/hitlercomparison.Rmd
  7. +3
    -2
      vignettes/interaction.Rmd

+ 1
- 0
NAMESPACE Näytä tiedosto

@@ -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)


+ 15
- 0
R/parse.R Näytä tiedosto

@@ -271,3 +271,18 @@ read_from_csv <- function(path="inst/csv/") {
is_valid_res(res) is_valid_res(res)
res res
} }

#' @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
}

+ 3
- 2
vignettes/explicittopic.Rmd Näytä tiedosto

@@ -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


+ 5
- 2
vignettes/genderequality.Rmd Näytä tiedosto

@@ -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


+ 3
- 2
vignettes/generalquestions.Rmd Näytä tiedosto

@@ -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


+ 3
- 2
vignettes/hitlercomparison.Rmd Näytä tiedosto

@@ -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


+ 3
- 2
vignettes/interaction.Rmd Näytä tiedosto

@@ -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


Loading…
Peruuta
Tallenna