---
title: Products with the same name but different active ingredients in the Swiss Register of Plant Protection Products
author: Johannes Ranke
date: Last change 3 March 2026 (rebuilt `r Sys.Date()`)
output:
  rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Products with the same name but different active ingredients in the Swiss Register of Plant Protection Products}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = TRUE, message = FALSE}
knitr::opts_chunk$set(tidy = FALSE, cache = FALSE)
options(knitr.kable.NA = '')
library(srppphist)
library(dplyr)
library(knitr)
library(flextable)
```

The main table generated in this vignette shows the names under which products 
with different active ingredient combinations were registered between 2011 and 
2026 in the Swiss Register of Plant Protection Products.

In most cases, simply a different active ingredient name was chosen for the same
active ingredient. For example, a content of propamocarb-hydrochlorid 
was later given in terms of the cation propamocarb, and a content of 
tribenuron-methyl was later expressed in terms of the corresponding acid
tribenuron. In  other cases, one or more active substances were replaced by an 
alternative substance. In at least one case, a product name was even used
for a different application area: The name "Auxilior Rex" was used for a 
fungicide in the 2011 register, and is used for a herbicide since 2016.

```{r}
srppp_products |> 
  filter(name == "Auxilior Rex") |> 
  select(chNbr, name, categories_de, earliest, latest)
```

Sometimes, a complete set of active ingredients
was apparently replaced by a different set of active ingredients. In the case
of the product name "Dominator", three very different active ingredient compositions
were registered under this name.

```{r different_ais}
chNbr_ais <- srppp_compositions |> 
  filter(type == "ACTIVE_INGREDIENT") |>  
  select(pNbr, pk, percent, g_per_L) |> 
  left_join(srppp_products, by = "pNbr", relationship = "many-to-many") |> 
  left_join(srppp_substances[c("pk", "substance_de")], by = "pk") |> 
  arrange(pNbr, pk) |> 
  group_by(pNbr, chNbr, name, earliest = earliest, latest = latest) |> 
  summarise(ais = paste(substance_de, collapse = ", "), .groups = "drop")

names_different_ais <- chNbr_ais |>
  distinct(name, ais) |> # Look for distinct combinations of name and ais
  summarise(n = n(), .by = "name") |> 
  filter(n > 1) |> 
  pull(name)
  
different_ais <- chNbr_ais |> 
  filter(name %in% names_different_ais) |> 
  select(name, ais, earliest, latest, ais, chNbr) |> 
  arrange(name, earliest, latest, ais, chNbr)

different_ais |> 
  mutate(across(earliest:latest, as.character)) |> 
  flextable() |> 
  set_header_labels(name = "Product name", ais = "Active ingredients", 
    chNbr = "Registration ID", earliest = "Earliest", latest = "Latest") |> 
  theme_box() |> 
  merge_v(j = ~ name) |> 
  merge_v(j = ~ ais) |> 
  set_table_properties(width = 1, layout = "autofit")
```

