as_survey: Creates basic survey table from votes in percent

View source: R/as-survey.R

as_surveyR Documentation

Creates basic survey table from votes in percent

Description

This functions takes votes in percent (per party) obtained from a survey, and returns a table containing votes (in percent) and party names. Conducts sanity checks along the way, such as checking that percentages add up to 1.

Usage

as_survey(
  percent,
  samplesize,
  parties = c("cdu", "spd", "gruene", "fdp", "linke", "piraten", "afd", "fw",
    "sonstige"),
  epsilon = 1e-05
)

Arguments

percent

Votes in percent each party received in the survey of interest. Can be set to NA, if parties are specified that are not mentioned in the specific survey (otherwise the parties argument has to be modified).

samplesize

Number of respondents in survey.

parties

Vector of same length and in the same order as percent

epsilon

The parameter percent should add up to one. This parameter controls the maximal numerical divergence allowed.

Value

A data.frame containing input and absolute number of votes in survey per party.

See Also

redistribute

Examples

forsa <- as_survey(
 percent    = c(0.41, 0.24, 0.13, 0.04, 0.08, 0.03, 0.03, 0.04),
 samplesize = 2508,
 parties    = c("cdu/csu", "spd", "gruene", "fdp", "linke", "piraten", "afd", "others"))
forsa

coalitions documentation built on Aug. 17, 2022, 5:07 p.m.