add documentations
This commit is contained in:
+31
-2
@@ -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
|
||||
|
||||
@@ -194,7 +194,7 @@ parse_speechlist <- function(speechlist_xml, date) {
|
||||
}
|
||||
|
||||
# create a tibble of speaker from a list of xml nodes representing speaker
|
||||
parse_speakerliste <- function(speakerliste_xml) {
|
||||
parse_speakerlist <- function(speakerliste_xml) {
|
||||
d <- sapply(speakerliste_xml, parse_speaker)
|
||||
tibble(id = d["id",],
|
||||
vorname = d["vorname",],
|
||||
|
||||
Reference in New Issue
Block a user