https://github.com/pachadotdev/freedomhouse
The goal of freedom is to ease the usage of the Freedom in the World dataset from Freedom House in R. The Freedom in the World dataset is updated annually and is originally available for download in Excel format.
https://github.com/pachadotdev/freedomhouse
freedom nlp r
Last synced: 6 months ago
JSON representation
The goal of freedom is to ease the usage of the Freedom in the World dataset from Freedom House in R. The Freedom in the World dataset is updated annually and is originally available for download in Excel format.
- Host: GitHub
- URL: https://github.com/pachadotdev/freedomhouse
- Owner: pachadotdev
- License: cc0-1.0
- Created: 2023-06-07T21:41:20.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-12T18:00:32.000Z (almost 2 years ago)
- Last Synced: 2025-02-28T22:41:08.923Z (over 1 year ago)
- Topics: freedom, nlp, r
- Language: R
- Homepage: https://pacha.dev/freedomhouse/
- Size: 124 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# Freedom House Datasets in R 
The goal of freedomhouse is to ease the usage of the Freedom in the World
dataset from Freedom House in R. The Freedom in the World dataset is updated
annually and is originally available for download in Excel format.
Freedom House is best known for political advocacy surrounding issues of
Democracy, Political Freedom, and Human Rights. Each of these issues trascends
political colours. The Freedom in the World dataset is a comprehensive and
widely used measure of political freedom. It is used by academics, journalists,
and policy makers alike.
My added value is to presents all the tables in a really simple to use format
and to make all the texts with the justifications for each sub-item scores,
that you find in around 1,000 links of the form
https://freedomhouse.org/country/canada/freedom-world/2023, available in a
single tidy table. This is useful for text mining and sentiment analysis.
I provided an Excel version of the final result in addition to the R datasets.
It can be downloaded [here](https://github.com/pachadotdev/freedomhouse/raw/main/exported-spreadsheets/freedom-house-excel.zip).
Another addition of mine was is to add translations. This work is not
affiliated with Freedom House.
## Installation
You can install the development version of freedom from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("pachadotdev/freedomhouse")
```
To install a translation, such as the Spanish translation, you can use:
```r
remotes::install_github("pachadotdev/freedomhouse", subdir = "translations/es")
```
## Example
This is a basic example which shows you how to use the available three tables.
```{r example, warning=FALSE, message=FALSE}
library(dplyr)
library(freedomhouse)
# Search Canada in 2023
country_rating_status %>%
filter(country == "Canada", year == 2023)
# Search for the "trade union" sub item score for Canada
country_score %>%
filter(country == "Canada", year == 2023) %>%
filter(grepl("trade union", sub_item_description)) %>%
select(sub_item_description)
# Get the full description of the "trade union" sub-item
country_score %>%
filter(sub_item == "E3") %>%
distinct(sub_item_description)
# Get the justification for the score on sub item E3
country_rating_text %>%
filter(
iso3c == "CAN",
year == 2023,
sub_item == "E3"
) %>%
pull(detail)
```
## Shiny
There is an example with Shiny [here](https://github.com/pachadotdev/freedomhouse/tree/main/shiny-demo).
## Translations
### Templates in Excel
The directory `dev/texts` contains the Excel files that I used for the
translations in `dev/texts/translation_es`. These can be used as templates for
translations to other languages different from Spanish.
What I did to add the translations in R was to use the `left_join` function
from the `dplyr` package to match each country/item/sub-item with the
corresponding translation.
### Spanish
Replica del ejemplo anterior.
```r
# remotes::install_github("pachadotdev/freedomhouse", subdir = "translations/es")
library(dplyr)
library(freedomhouse)
estado_calificacion_pais %>%
filter(pais == "Canadá", anio == 2023)
# # A tibble: 1 × 9
# anio pais iso2c iso3c continente derechos_politicos libertades_civiles
#
# 1 2023 Canadá CA CAN Américas 1 1
# # ℹ 2 more variables: estado , color
puntaje_pais %>%
filter(pais == "Canadá", anio == 2023) %>%
filter(grepl("sindicato", descripcion_sub_categoria)) %>%
select(sub_categoria)
# # A tibble: 1 × 1
# sub_categoria
#
# 1 E3
puntaje_pais %>%
filter(sub_categoria == "E3") %>%
distinct(descripcion_sub_categoria)
# # A tibble: 1 × 1
# descripcion_sub_categoria
#
# 1 ¿Existe libertad para los sindicatos y organizaciones profesionales o laboral…
# Get the justification for the score on sub item E3
texto_calificacion_pais %>%
filter(
iso3c == "CAN",
anio == 2023,
sub_categoria == "E3"
) %>%
pull(detalle)
# [1] Los sindicatos y las asociaciones empresariales gozan de un alto nivel de afiliación y están bien organizados.
# 27269 Levels: La calificación de derechos políticos de Afganistán mejoró de 6 a 5 debido a una mayor actividad política de la oposición antes de las elecciones programadas, así como a modestos avances en la transparencia del gobierno. ...
```
## Development
To verify the changes made to the package, run the following commands:
```r
devtools::document()
attachment::att_amend_desc()
devtools::check()
```