Description Usage Arguments Value Author(s) Examples
View source: R/convert_esaps.R
Convert data in table format to tidy_data to use in the indicators of the tidy_data.
1 2 3 4 5 6 7 8 9 10 11 12 |
path |
Character vector containing one or more path names. |
dataset |
Electoral results by party. It can be a |
file.name |
Name of the data file with extension. |
nSheets |
Number of countries (number of sheets).' 'Country' is a generic unit of analysis (province, department, etc.) |
election.name |
Name of the variable that contains elections. |
unit.name |
Name of the variable that contains the unit. 'unit' is a generic unit of analysis (province, department, etc.) |
M.name |
Name of the variable that contains the district magnitude (M+1). It is for the calculation of endogenous and exogenous electoral volatility (Torcal and Lago, 2015). |
votes_nac.name |
la la la |
seats |
By default it is |
allSheet |
By default it is |
data.frame
Nicolas Schmidt nschmidt@cienciassociales.edu.uy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | votes <- list(data.frame(country = rep("ARG", 3),
year = c(1995, 2000, 2005),
party_A = c(40,10,20),
party_B = c(35,20,40),
party_C = c(25,70,40)),
data.frame(country = rep("URY", 4),
year = c(1995, 2000, 2005, 2010),
party_A = c(30,30,20,20),
party_B = c(30,50,40, 30),
party_C = c(30,10,30, 25),
party_D = c(10,10,10,25)),
data.frame(country = rep("BRA", 2),
year = c(1993, 1998),
party_A = c(30, 55),
party_B = c(70, 45)))
votes <- convert_esaps(dataset = votes, unit.name = "country", election.name = "year")
votes2 <- data.frame(year = c(2000, 2005),
country = "URY",
votes_party1 = c(20, 30),
votes_party2 = c(30, 35),
votes_party3 = c(40, 25),
votes_party4 = c(10, 10),
seats_party1 = c(25, 35),
seats_party2 = c(20, 30),
seats_party3 = c(40, 30),
seats_party4 = c(15, 5))
votes <- convert_esaps(dataset = votes2, unit.name = "country", election.name = "year",
seats = TRUE)
## Not run:
v1 <- convert_esaps(path = getwd(),
file.name = c("electionBRA.xlsx", "electionARG.xlsx"),
election.name = "elec",
unit.name = "district",
allSheet = TRUE)
v2 <-convert_esaps(path = getwd(),
file.name = c("ARG.ods", "URY.ods", "BRA.ods"),
nCountry = c(2, 3, 1),
election.name = "elec",
unit.name = "province")
v3 <- convert_esaps(path = here::here(),
file.name = list.files(pattern = "*.xlsx"),
election.name = "year",
unit.name = "country",
M.name = "magnitude",
seats = TRUE,
allSheet = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.