inst/roxygen-examples/dot-check_if_pkgs_are_installed-example.R

# Succeeds silently (base packages are always available)
.check_if_pkgs_are_installed(
  pkgs = c("stats"),
  function_name = "my_fun"
)

# Same check but for an R6 class context
.check_if_pkgs_are_installed(
  pkgs = c("utils"),
  class_name = "MyClass"
)

# This will error with an informative message
try(
  .check_if_pkgs_are_installed(
    pkgs = c("definitelyNotAPackage123", "alsoNotAPackage456"),
    function_name = "my_fun"
  )
)
try(
  .check_if_pkgs_are_installed(
    pkgs = c("definitelyNotAPackage123", "alsoNotAPackage456"),
    class_name = "MyClass"
  )
)

Try the causalDisco package in your browser

Any scripts or data that you put into this service are public.

causalDisco documentation built on April 13, 2026, 5:06 p.m.