percchange: Given the total number of seats, it calculates the percentage...

Description Usage Arguments Value Examples

View source: R/percchange.R

Description

This function is similar to percseats, but it calculates percentage of held seats by each party in each country by using the value from a "Total" column that has the total number of seats available per country. As a result, this function works even if the sum of all columns do not equal the total value of seats.

Usage

1
percchange(df, columns, keep = c("Country", "Total"))

Arguments

df

The dataframe with the data on the seats held by the political parties.

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 "Total".

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.

Examples

1
2
3
4
5
6
7
8
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)
Total <- c(4,6,8)
df.data <- data.frame(Country, EPP, SD, Other, IN, Total)
percchange(df.data, columns = c("EPP", "SD", "Other", "IN"))

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