An R package to analyze the parliamentary records of the 19th legislative period of the Bundestag, the German parliament.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

27 lines
882B

  1. `%$%` <- function(f, x) f(x)
  2. `%.%` <- function(f, g) function(...) f(g(...))
  3. flip <- function(f) function(x, y) f(y, x)
  4. clear_na <- function(xs) xs[!is.na(xs)]
  5. check_directory <- function(path, create=F) {
  6. # check if download_dir exists
  7. if(file.access(path, mode=0) == -1) {
  8. if (create) {
  9. tryCatch(dir.create(path),
  10. error = stop_dir_not_creatable,
  11. warning = stop_dir_not_creatable)
  12. } else {
  13. stop("Directory does not exist. Use create = TRUE if you wish to create the directory.")
  14. }
  15. } else if (file.access(path, mode=2) == -1) {
  16. stop("Directory exists, but is not writeable.")
  17. }
  18. }
  19. # appends a file seperator at end of path if needed
  20. make_directory_path <- function(path) {
  21. if (!str_ends(path, .Platform$file.sep)) str_c(path, .Platform$file.sep)
  22. else path
  23. }