# 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)
Run the code above in your browser using DataLab