R/zzz.R

Defines functions .onLoad .onAttach is_attached

# ==================================================================== #
# TITLE                                                                #
# Tools for Data Analysis at Certe                                     #
#                                                                      #
# AUTHORS                                                              #
# Berends MS (m.berends@certe.nl)                                      #
# Meijer BC (b.meijer@certe.nl)                                        #
# Hassing EEA (e.hassing@certe.nl)                                     #
#                                                                      #
# COPYRIGHT                                                            #
# (c) 2019 Certe Medische diagnostiek & advies - https://www.certe.nl  #
#                                                                      #
# LICENCE                                                              #
# This R package is free software; you can redistribute it and/or      #
# modify it under the terms of the GNU General Public License          #
# version 2.0, as published by the Free Software Foundation.           #
# This R package is distributed in the hope that it will be useful,    #
# but WITHOUT ANY WARRANTY; without even the implied warranty of       #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         #
# GNU General Public License for more details.                         #
# ==================================================================== #

.onLoad <- function(libname, pkgname) {
  # importeren van functies die nog niet in de R-versie van de gebruiker zitten:
  backports::import(pkgname)
}

core <- c("ggplot2", "tibble", "tidyr", "readr", "readxl",
          "purrr", "dplyr", "stringr", "forcats", "lubridate", 
          "xml2", "httr", "rvest",
          "cleaner", "AMR", "extrafont", "certedata")

.onAttach <- function(...) {
  needed <- core[!is_attached(core)]
  if (length(needed) == 0)
    return()
  
  crayon::num_colors(TRUE)
  certedata_attach()
 
  if (!"package:conflicted" %in% search()) {
    x <- certedata_conflicts()
    x <- x[sapply(x, function(y) !any(y %like% "package:(base|datasets|graphics|grDevices|methods|stats|utils)"))]
    x <- structure(x, class = "certedata_conflicts")
    msg(certedata_conflict_message(x), startup = TRUE)
  }
}

is_attached <- function(x) {
  paste0("package:", x) %in% search()
}
msberends/certedata documentation built on Nov. 26, 2019, 5:19 a.m.