diff --git a/R/analyze.R b/R/analyze.R index 43aa990..30f2774 100644 --- a/R/analyze.R +++ b/R/analyze.R @@ -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 diff --git a/R/parse.R b/R/parse.R index aa7ceb6..55f17dd 100644 --- a/R/parse.R +++ b/R/parse.R @@ -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",], diff --git a/man/bar_plot_fractions.Rd b/man/bar_plot_fractions.Rd new file mode 100644 index 0000000..e308374 --- /dev/null +++ b/man/bar_plot_fractions.Rd @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/analyze.R +\name{bar_plot_fractions} +\alias{bar_plot_fractions} +\title{Bar chart of the fractions} +\usage{ +bar_plot_fractions( + tb, + x_variable = NULL, + y_variable = NULL, + fill = NULL, + title = NULL, + xlab = "Fraction", + ylab = "n", + filllab = "Fraction", + flipped = TRUE, + position = "dodge", + reorder = FALSE +) +} +\arguments{ +\item{tb}{The tibble to be analyzed.} + +\item{x_variable}{Default is fraction.} + +\item{y_variable}{Default is n.} + +\item{fill}{Default is fraction.} + +\item{title}{Title of the chart.} + +\item{xlab}{Description of x-Lab. Default is Fraction.} + +\item{ylab}{Description of y-Lab. Default is n.} + +\item{filllab}{Default is Fraction.} + +\item{flipped}{Default is TRUE. If TRUE draw bars horizontally, else vertically.} + +\item{position}{Default is dodge.} + +\item{reorder}{Either reorder fraction factor by variable value or reorder fraction factor by party seat order in parliament (default).} +} +\description{ +Bar chart of the fractions +} diff --git a/man/join_speaker.Rd b/man/join_speaker.Rd new file mode 100644 index 0000000..a30fb22 --- /dev/null +++ b/man/join_speaker.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/analyze.R +\name{join_speaker} +\alias{join_speaker} +\title{Assign speaker-name to speaker-ID} +\usage{ +join_speaker(tb, res, fraction_only = F) +} +\arguments{ +\item{tb}{tibble} + +\item{res}{list of tibbles} + +\item{fraction_only}{If TRUE select only from "fraction"} +} +\description{ +Assign speaker-name to speaker-ID. +} diff --git a/man/party_colors.Rd b/man/party_colors.Rd new file mode 100644 index 0000000..e4417b6 --- /dev/null +++ b/man/party_colors.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/analyze.R +\docType{data} +\name{party_colors} +\alias{party_colors} +\title{Assignment of the official colors to the parties} +\format{ +An object of class \code{character} of length 8. +} +\usage{ +party_colors +} +\description{ +Assignment of the official colors to the parties +} +\keyword{datasets} diff --git a/man/word_usage_by_date.Rd b/man/word_usage_by_date.Rd new file mode 100644 index 0000000..4d897a8 --- /dev/null +++ b/man/word_usage_by_date.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/analyze.R +\name{word_usage_by_date} +\alias{word_usage_by_date} +\title{Word usage summarised by date} +\usage{ +word_usage_by_date(res, patterns, name, tidy = F) +} +\arguments{ +\item{res}{List of Tibbles to be analysed.} + +\item{patterns}{Words to look up.} + +\item{name}{?} + +\item{tidy}{Default is FALSE.} +} +\description{ +Counts how many talks do match a given pattern and summarises by date. +} diff --git a/vignettes/genderequality.Rmd b/vignettes/genderequality.Rmd index d291bd2..d4aa64d 100644 --- a/vignettes/genderequality.Rmd +++ b/vignettes/genderequality.Rmd @@ -88,7 +88,9 @@ text %>% str_trim() -> names -gender <- tibble(name = names, +gender <- tibble(speaker = names, gender = gender) + + ```