Learn R Programming

coalitions (version 0.6.24)

as_survey: 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
)

Value

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

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.

See Also

redistribute

Examples

Run this code
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

Run the code above in your browser using DataLab