add documentations

This commit is contained in:
Leon Burgard
2021-08-06 19:07:35 +02:00
parent 1433159e09
commit d5da636020
7 changed files with 135 additions and 4 deletions
+31 -2
View File
@@ -5,6 +5,14 @@ find_word <- function(res, word) {
nrow))
}
#'Assign speaker-name to speaker-ID
#'
#' Assign speaker-name to speaker-ID.
#'
#' @param tb tibble
#' @param res list of tibbles
#' @param fraction_only If TRUE select only from "fraction"
#'
#' @export
join_speaker <- function(tb, res, fraction_only = F) {
joined <- left_join(tb, res$speaker, by=c("speaker" = "id"))
@@ -30,6 +38,20 @@ party_order <- factor(c("Fraktionslos", "AfD&Fraktionslos",
"DIE LINKE", "BÜNDNIS 90 / DIE GRÜNEN", "SPD", "CDU/CSU",
"FDP", "AfD", NA_character_))
#'Bar chart of the fractions
#'
#' @param tb The tibble to be analyzed.
#' @param x_variable Default is fraction.
#' @param y_variable Default is n.
#' @param fill Default is fraction.
#' @param title Title of the chart.
#' @param xlab Description of x-Lab. Default is Fraction.
#' @param ylab Description of y-Lab. Default is n.
#' @param filllab Default is Fraction.
#' @param flipped Default is TRUE. If TRUE draw bars horizontally, else vertically.
#' @param position Default is dodge.
#' @param reorder Either reorder fraction factor by variable value or reorder fraction factor by party seat order in parliament (default).
#'
#' @export
bar_plot_fractions <- function(tb,
x_variable = NULL, # default is fraction
@@ -73,8 +95,15 @@ bar_plot_fractions <- function(tb,
if (flipped) plt + coord_flip() else plt
}
# Counts how many talks do match a given pattern and summarises by date
#
#'Word usage summarised by date
#'
#' Counts how many talks do match a given pattern and summarises by date.
#'
#' @param res List of Tibbles to be analysed.
#' @param patterns Words to look up.
#' @param name ?
#' @param tidy Default is FALSE.
#'
#' @export
word_usage_by_date <- function(res, patterns, name, tidy=F) {
tb <- res$talks