Funcion que describe el grado de competencia de una eleccion (Function that describes the degree of competition of an election)
compute_competitiveness(data, level = "provincia")un tibble guardado como objeto en el Enviroment luego de consultar get_election_data
(A tibble saved as an object in the Enviroment after querying get_election_data).
un character que establece el nivel de agregacion sobre el que se quiere calcular la competitividad:
por defualt es provincia y se desagregan las observaciones asignando los valores departamento o circuito al parametro
(Establishes the level of aggregation on which you want to compute competitiveness: by definition it is provincia
and the observations are disaggregated by assigning the values departamento or circuito to the parameter).
devuelve un tibble con class "tbl_df","tbl", "data.frame" con el computo de competitividad de una elccion. El resultado puede
ser un valor entre 0 y 1,
los cuales representan falta de competencia y competitivdad maxima, respectivamente
(returns a tibble with class "tbl_df", "tbl", "data.frame" with the computation of the level of competitiveness of an elction.
The result can be a value between 0 and 1, which represent a lack of competition and maximum competitiveness, respectively).
\(Competitividad\) mide la diferencia porcentual de votos v<U+00E1>lidos obtenidos por los dos partidos m<U+00E1>s votados \(a\) y \(b\). Puede tomar valores entre \([0,1]\) donde \(1\) es lo m<U+00E1>s comeptitivo (\(a = 50\%\) y \(b = 50\%\) de los votos). La f<U+00F3>rmula utilizada es: $$Competitividad = 1 - (a - b)$$
REQUISITO:
El formato de data debe ser long para calcular compute_competitiveness.
Si data es wide se puede transformar con make_long
(long format of data is required for compute_competitiveness. If data is in wide format
you can transform it with make_long).
# NOT RUN {
tucuman_dip_gral_2017
tucuman_dip_gral_2017 %>%
compute_competitiveness()
# }
Run the code above in your browser using DataLab