Просмотр исходного кода

add documentations

genderequality-alternative
Leon Burgard 4 лет назад
Родитель
Сommit
d5da636020
7 измененных файлов: 135 добавлений и 4 удалений
  1. +31
    -2
      R/analyze.R
  2. +1
    -1
      R/parse.R
  3. +46
    -0
      man/bar_plot_fractions.Rd
  4. +18
    -0
      man/join_speaker.Rd
  5. +16
    -0
      man/party_colors.Rd
  6. +20
    -0
      man/word_usage_by_date.Rd
  7. +3
    -1
      vignettes/genderequality.Rmd

+ 31
- 2
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


+ 1
- 1
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",],


+ 46
- 0
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
}

+ 18
- 0
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.
}

+ 16
- 0
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}

+ 20
- 0
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.
}

+ 3
- 1
vignettes/genderequality.Rmd Просмотреть файл

@@ -88,7 +88,9 @@ text %>%
str_trim() ->
names

gender <- tibble(name = names,
gender <- tibble(speaker = names,
gender = gender)


```


Загрузка…
Отмена
Сохранить