percseats: Function that calculates the percentage of possible seats per...

Description Usage Arguments Details Value Examples

View source: R/percseats.R

Description

This function calculates the percentage of possible seats a party got in each country. That is the number of seats gained by Party(1) in country(a) as a percentage of total seats that country(a) has in the EU Parliament for any given year.

Usage

1
percseats(df, columns, keep = c("Country", "Year"))

Arguments

df

The dataframe with the data of the political parties and the seats they hold.

columns

The vector of parties or political groups to be considered.

keep

What columns of the inputed dataframe will be kept. By default, it will be "Country" and "Year".

Details

Warning: This function will return the percentage of each column compared to all selected columns. Therefore, if not all parties/political groups are selected, the function will not return the percentage of all possible seats within each country.

Value

Returns a dataframe containing the rows from the inputted dataframe listed in keep and the columns assigned to argument columns and returns those values as percentages of total possible seats, rather than in absolute values and an extra column "country_seats" with the total number of available seats per country (in other words, the sum of each column's values).

Examples

1
2
3
4
5
6
7
Country <- c("Austria", "Belgium", "Bulgaria")
EPP <- c(1,2,3)
SD <- c(1,2,3)
Other <- c(1,1,1)
IN <- c(1,1,1)
df.data <- data.frame(Country, EPP, SD, Other, IN)
percseats(df.data, columns = c("EPP", "SD", "Other", "IN"), keep = "Country")

bclroger/euparliament documentation built on Jan. 26, 2020, 12:56 a.m.