---
title: "Sector Classification"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Sector Classification}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup, echo = FALSE, message = FALSE}
library(pacta.loanbook)

plot_table <- function(dataset_name) {
  table <- data_dictionary
  table <- dplyr::filter(table, .data[["dataset"]] == dataset_name)
  table <- dplyr::arrange(table, match(column, names(get(dataset_name))))
  table_plot <- gt::gt(dplyr::select(table, -"dataset"))
  
  table_plot <- 
    gt::cols_width(
      .data = table_plot,
      column ~ gt::px(150),
      typeof ~ gt::px(90)
    )
  
  table_plot <-
    gt::tab_style(
      data = table_plot,
      style = gt::cell_text(size = "smaller"),
      locations = gt::cells_body(columns = 1:2)
    )
  
  table_plot <-
    gt::tab_options(
      data = table_plot,
      ihtml.active = TRUE,
      ihtml.use_pagination = FALSE,
      ihtml.use_sorting = TRUE,
      ihtml.use_highlight = TRUE
    )
  
  gt::fmt_passthrough(table_plot)
}
```

## sector classifications dataset

This dataset contains all currently supported translation keys between the sector classification systems and sector scopes used in the 'PACTA' software.

```{r, echo = FALSE}
plot_table("sector_classifications")
```

The `{pacta.loanbook}` package provides a sector classification dataset `sector_classifications` that contains a sector mapping for all supported sector classification systems (currently: `r paste0(unique(sector_classifications$code_system), collapse = ", ")`).

```{r, R.options = list(width = 400)}
sector_classifications
```

## GICS classification dataset

This dataset serves as a translation key between the GICS sector-classification system and sector scopes used in the 'PACTA' software.

```{r, echo = FALSE}
plot_table("gics_classification")
```

The `{pacta.loanbook}` package provides a GICS classification dataset `gics_classification`.

```{r, R.options = list(width = 400)}
gics_classification
```

## ISIC Rev 5 classification dataset

This dataset serves as a translation key between the ISIC Rev 5 sector-classification system and sector scopes used in the 'PACTA' software.


```{r, echo = FALSE}
plot_table("isic_classification")
```

The `{pacta.loanbook}` package provides a ISIC Rev 5 classification dataset `isic_classification`.

```{r, R.options = list(width = 400)}
isic_classification
```

## NACE version 2.1 classification dataset

This dataset serves as a translation key between the NACE version 2.1 sector-classification system and sector scopes used in the 'PACTA' software.

```{r, echo = FALSE}
plot_table("nace_classification")
```

The `{pacta.loanbook}` package provides a NACE version 2.1 classification dataset `nace_classification`.

```{r, R.options = list(width = 400)}
nace_classification
```

## PSIC classification dataset

This dataset serves as a translation key between the PSIC sector-classification system and sector scopes used in the 'PACTA' software.

```{r, echo = FALSE}
plot_table("psic_classification")
```

The `{pacta.loanbook}` package provides a PSIC classification dataset `psic_classification`.

```{r, R.options = list(width = 400)}
psic_classification
```

## SIC classification dataset

This dataset serves as a translation key between the SIC sector-classification system and sector scopes used in the 'PACTA' software.

```{r, echo = FALSE}
plot_table("sic_classification")
```

The `{pacta.loanbook}` package provides a SIC classification dataset `sic_classification`.

```{r, R.options = list(width = 400)}
sic_classification
```
