Skip to content

Commit

Permalink
Merge pull request #81 from adibender/devel
Browse files Browse the repository at this point in the history
Typos/spell check
  • Loading branch information
adibender authored Mar 11, 2018
2 parents d4bc46a + b9f96f2 commit d57488f
Show file tree
Hide file tree
Showing 56 changed files with 131 additions and 131 deletions.
2 changes: 1 addition & 1 deletion R/DHondt.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param votes Number of votes per party.
#' @param parties Names of parties (must be same length as votes).
#' @param n_seats Number of seats in parliament. Defaults to 183 (seats in
#' austrian parliament).
#' Austrian parliament).
#' @seealso \code{\link{sls}}
#' @importFrom reshape2 melt
#' @return A \code{data.frame} containing parties above the hurdle and the respective
Expand Down
6 changes: 3 additions & 3 deletions R/coalition-probability.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ has_majority <- function(
#' @inheritParams has_majority
#' @inheritParams paste_coalitions
#' @inheritParams calculate_probs
#' @param seats_tab A data frame cotaining number of seats obtained by a party.
#' @param seats_tab A data frame containing number of seats obtained by a party.
#' Must have columns \code{party} and \code{seats}.
#' @importFrom purrr map
#' @importFrom dplyr bind_cols
Expand Down Expand Up @@ -93,7 +93,7 @@ paste_coalitions <- function(coalitions, collapse="_") {
#'
#' @param majority_df A data frame containing logical values indicating
#' if the coalitions (columns) have a majority (rows).
#' @param coalition The coaliton of interest for which superior coalitions
#' @param coalition The coalition of interest for which superior coalitions
#' will be obtained by \code{\link[coalitions]{get_superior}}.
#' @param exclude_superior Logical. If \code{TRUE}, superior coalitions will
#' be excluded, otherwise total coalition probabilities will be returned.
Expand Down Expand Up @@ -131,7 +131,7 @@ calculate_prob <- function(
#' Calculate coalition probabilities for multiple coalitions
#'
#' @inherit calculate_prob
#' @param coalitions A list of coaltions for which coalition probabilities should
#' @param coalitions A list of coalitions for which coalition probabilities should
#' be calculated. Each list entry must be a vector of party names. Those names
#' need to correspond to the names in \code{majority_df}.
#' @importFrom dplyr bind_cols
Expand Down
14 changes: 7 additions & 7 deletions R/draw-from-posterior.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
#' @param nsim number of simulations
#' @param seed sets seed
#' @param prior optional prior information. Defaults to 1/2 (Jeffrey's prior).
#' @param correction A positiv number. If not \code{NULL}, each sample from the
#' dirichlet distribution will be additionally "corrected" by a random number
#' @param correction A positive number. If not \code{NULL}, each sample from the
#' Dirichlet distribution will be additionally "corrected" by a random number
#' from U(-1*correction, 1*correction). This can be used to introduce extra
#' variation which might be usefull due to rounding errors from reported survey
#' results (or add an aditional source of variation in general).
#' variation which might be useful due to rounding errors from reported survey
#' results (or add an additional source of variation in general).
#'
#' @importFrom gtools rdirichlet
#' @importFrom dplyr tbl_df
#' @importFrom lubridate now
#' @importFrom stats runif
#' @return \code{data.frame} containing random draws from dirichlet distribution
#' @return \code{data.frame} containing random draws from Dirichlet distribution
#' which can be interpreted as election results.
#' @keywords draw, simulate
#' @seealso \code{\link{as_survey}}
Expand All @@ -37,7 +37,7 @@ draw_from_posterior <- function(
}
n_votes <- sum(survey$votes)
percent <- survey$percent/100
# draw n.sim random dirichlet numbers/vectors with concentration weights alpha
# draw n.sim random Dirichlet numbers/vectors with concentration weights alpha
# draws <- rdirichlet(nsim, alpha = survey$votes + prior)
# colnames(draws) <- survey$party

Expand All @@ -58,7 +58,7 @@ draw_from_posterior <- function(
warning(paste0(
"Some drawn percentages were smaller than 0.\n ",
"The value of the correction may be to large.\n ",
"Draws with negative percentages will be excluded, which may leed to bias."))
"Draws with negative percentages will be excluded, which may lead to bias."))
}

alpha <- corrections * n_votes + prior
Expand Down
4 changes: 2 additions & 2 deletions R/hare_niemeyer.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param votes Number of votes per party.
#' @param parties Names of parties (must be same length as votes).
#' @param n_seats Number of seats in parliament. Defaults to 183 (seats in
#' austrian parliament).
#' Austrian parliament).
#' @seealso \code{\link{sls}}
#' @importFrom reshape2 melt
#' @return A \code{data.frame} containing parties above the hurdle and the respective
Expand All @@ -26,5 +26,5 @@ hare_niemeyer <- function(votes, parties, n_seats = 183) {
rest[m_i] <- 0
}
seats

}
8 changes: 4 additions & 4 deletions R/pooling.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' This is the work horse function that calculates the effective sample size.
#' Should usually not be called by the user directly.
#'
#' @param size A vecotr of sample sizes from different surveys (from different
#' @param size A vector of sample sizes from different surveys (from different
#' pollsters) for one party.
#' @param share The relative share of votes for party of interest ([0-1])
#' @param corr Assumed correlation between surveys (of different pollsters).
Expand Down Expand Up @@ -59,7 +59,7 @@ effective_samplesize <- function(

}

#' Extract surveys from insitutes within a specfied time-window
#' Extract surveys from institutes within a specified time-window
#'
#'
#' @param surveys A \code{tibble} containing survey results for multiple
Expand All @@ -72,7 +72,7 @@ effective_samplesize <- function(
#' @param period See \code{last_date} argument.
#' @param period_extended Optional. If specified, all surveys in the time-window
#' from \code{last_date} - period_extended to \code{last_date} - period will
#' also be considered for each pollster, but only after downweighting them by
#' also be considered for each pollster, but only after down-weighting them by
#' halving their true sample size.
#' @import dplyr checkmate
#' @keywords internal
Expand Down Expand Up @@ -235,7 +235,7 @@ pool_surveys <- function(

}

#' Total number of survey participants from surveys elligible for pooling.
#' Total number of survey participants from surveys eligible for pooling.
#'
#' @param eligible_df A data frame containing surveys that should be used for
#' pooling as returned by \code{get_eligible}.
Expand Down
4 changes: 2 additions & 2 deletions R/prettify.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#' Replace/prettify matching words/terms in one vector by another
#'
#' The function searches for \code{x} values, that occur in \code{current}
#' and replaces them with entries in \code{new}. Usefull for quick
#' and replaces them with entries in \code{new}. Useful for quick
#' renaming/translation of survey column names and by using internal object
#' \code{.trans_df}
#'
#' @rdname prettify
#' @param x A character vector (or factor) that should be renamed.
#' @param current A vector of characters (possibly subset of \code{x}).
#' Entries in \code{x} that match entries in \code{current} will be renamed
#' accroding to entries in \code{new}.
#' according to entries in \code{new}.
#' @param new A vector of characters that will replace entries in \code{x} which
#' have matches in \code{current}.
#' @importFrom purrr map2
Expand Down
2 changes: 1 addition & 1 deletion R/saint-lague-scheppers.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Seat Distribution by Sainte-Lague/Scheppers
#' Seat Distribution by Sainte-Lague/Schepers
#'
#' Calculates number of seats for the respective parties that have received more
#' than 5\% of votes (according to the method of Sainte-Lague/Schepers,
Expand Down
12 changes: 6 additions & 6 deletions R/scrapers.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Sanitze character vector
#' Sanitize character vector
#'
#' Substitute all german "Umlaute"
#' Substitute all German "Umlaute"
#' @param x A character vector.
#' @keywords internal
sanitize_strings <- function(x) {
Expand All @@ -18,7 +18,7 @@ sanitize_strings <- function(x) {

}

#' Extract numericals from string or character
#' Extract numerics from string or character
#'
#' Removes all characters that are not in [0-9].
#' @param x A character vector.
Expand Down Expand Up @@ -55,7 +55,7 @@ sanitize_colnames <- function(df) {

#' Scrape surveys from wahlrecht.de
#'
#' Scrapes survey tables and perfroms sanitization to output tidy data
#' Scrapes survey tables and performs sanitation to output tidy data
#' @rdname scrape
#' @param address http-address from which tables should be scraped.
#' @param parties A character vector containing names of parties to collapse.
Expand Down Expand Up @@ -297,7 +297,7 @@ get_surveys_nds <- function() {

}

#' Import austrian survey results
#' Import Austrian survey results
#'
#' Reads JSON file from neuwal.com
#' @param address URL of the JSON file
Expand All @@ -314,7 +314,7 @@ get_surveys_nds <- function() {
scrape_austria <- function(
address = "https://neuwal.com/wahlumfragen/openwal/neuwal-openwal.json") {

aut_list <- fromJSON(getURL(address) %>%
aut_list <- fromJSON(getURL(address) %>%
str_replace('\\"\\"(.*)\\"\\",', "\"'\\1'\",")) # fix for double double-quote bug
out_df <- as_tibble(aut_list) %>%
rename(survey = "results") %>%
Expand Down
8 changes: 4 additions & 4 deletions R/seat-distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#' @param survey The actual survey results on which \code{dirichlet.draws}
#' were based on.
#' @param distrib.fun Function to calculate seat distribution. Defaults to
#' \code{\link{sls}} (Sainte-Lague/Scheppers).
#' \code{\link{sls}} (Sainte-Lague/Schepers).
#' @param samplesize Number of individuals participating in the \code{survey}.
#' @param hurdle The percentage threshold which has to be reached by a party
#' to enter the parliament.
#' @param others A string indecating the name under which parties not listed
#' explicitly are subsummed.
#' @param others A string indicating the name under which parties not listed
#' explicitly are subsumed.
#' @param ... Further arguments passed to \code{distrib.fun}.
#' @import checkmate dplyr
#' @return A data frame containing seat distributions for each simulation in
Expand Down Expand Up @@ -63,7 +63,7 @@ redistribute <- function(
others = "others",
epsilon = 10e-6) {

# must be & (we include parties with percent > hurdel and name != others)
# must be & (we include parties with percent > hurdle and name != others)
survey <- survey[survey$percent >= hurdle & survey$party != others, ]

survey$percent <- survey$votes / sum(survey$votes)
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/calculate_prob.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/calculate_probs.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/dHondt.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions docs/reference/draw_from_posterior.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/effective_samplesize.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/reference/extract_num.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/filter_superior.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions docs/reference/get_eligible.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions docs/reference/get_n.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d57488f

Please sign in to comment.