srppp_dm {srppp}R Documentation

Create a dm object from an XML version of the Swiss Register of Plant Protection Products

Description

While reading in the data, the information obtained from the XML file is left unchanged, with the exceptions listed in the section 'Details'. An overview of the contents of the most important tables in the resulting data object is given in vignette("srppp").

Usage

srppp_dm(from = srppp_xml_url, remove_duplicates = TRUE, verbose = TRUE)

## S3 method for class 'srppp_dm'
print(x, ...)

Arguments

from

A specification of the way to retrieve the XML to be passed to srppp_xml_get, or an object of the class 'srppp_xml'

remove_duplicates

Should duplicates based on wNbrs be removed?

verbose

Should we give some feedback?

x

A srppp_dm object

...

Not used

Details

Corrections made to the data

Removal of redundant information

Amendments to the data

In the table of obligations, the following information on mitigation measures is extracted from the ones relevant for the environment (SPe 3).

Value

A dm::dm object with tables linked by foreign keys pointing to primary keys, i.e. with referential integrity. Since version 1.1, the returned object has an attribute named 'culture_tree' of class data.tree::Node.

Examples

 # Avoid NOTE on CRAN caused by checks >5s
library(dplyr, warn.conflicts = FALSE)
library(dm, warn.conflicts = FALSE)

sr <- try(srppp_dm())

# Fall back to internal test data if downloading or reading fails
if (inherits(sr, "try-error")) {
  sr <- system.file("testdata/Daten_Pflanzenschutzmittelverzeichnis_2024-12-16.zip",
      package = "srppp") |>
    srppp_xml_get_from_path(from = "2024-12-16") |>
    srppp_dm()
}

dm_examine_constraints(sr)
dm_draw(sr)

# Show ingredients for products named 'Boxer'
sr$products |>
  filter(name == "Boxer") |>
  left_join(sr$ingredients, by = "pNbr") |>
  left_join(sr$substances, by = "pk") |>
  select(wNbr, name, pNbr, isSalePermission, substance_de, g_per_L)

# Show authorised uses of the original product
boxer_uses <- sr$products |>
  filter(name == "Boxer", !isSalePermission) |>
  left_join(sr$uses, by = "pNbr") |>
  select(pNbr, use_nr,
    min_dosage, max_dosage, min_rate, max_rate, units_de,
    waiting_period, time_units_de, application_area_de)
print(boxer_uses)

# Show crop for use number 1
boxer_uses |>
  filter(use_nr == 1) |>
  left_join(sr$cultures, join_by(pNbr, use_nr)) |>
  select(use_nr, culture_de)

# Show target pests for use number 1
boxer_uses |>
  filter(use_nr == 1) |>
  left_join(sr$pests, join_by(pNbr, use_nr)) |>
  select(use_nr, pest_de)

# Show obligations for use number 1
boxer_uses |>
  filter(use_nr == 1) |>
  left_join(sr$obligations, join_by(pNbr, use_nr)) |>
  select(use_nr, sw_runoff_points, obligation_de) |>
  knitr::kable() |>
  print()

# Show application comments for use number 1
boxer_uses |>
  filter(use_nr == 1) |>
  left_join(sr$application_comments, join_by(pNbr, use_nr)) |>
  select(use_nr, application_comment_de)

# Illustrate 'obligations' indicating varying effects
sr$obligations |>
  filter(varying_effect) |>
  select(pNbr, use_nr, code, obligation_de)



[Package srppp version 1.1.0 Index]