knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
# Get all conflicting functions from two namespaces conflicts2 <- function(x, y) { Filter(Negate(function(x) grepl("\\.__T__", x)), intersect(getNamespaceExports(x), getNamespaceExports(y))) } # CRAN packages from https://support.rstudio.com/hc/en-us/articles/201057987-Quick-list-of-useful-R-packages CRAN <- c( "base", "stats", "graphics", "RMySQL", "RSQLite", "XLConnect", "xlsx", "foreign", "readr", "haven", "dplyr", "tidyr", "stringr", "lubridate", "ggplot2", "ggvis", "rgl", "htmlwidgets", "leaflet", "dygraphs", "DT", "DiagrammeR", "networkD3", "googleVis", "car", "mgcv", "lme4", "nlme", "randomForest", "multcomp", "vcd", "glmnet", "survival", "caret", "shiny", "rmarkdown", "knitr", "xtable", "sp", "maptools", "maps", "ggmap", "zoo", "xts", "quantmod", "Rcpp", "data.table", "parallel", "XML", "jsonlite", "httr", "rvest", "devtools", "testthat", "roxygen2") # Bioc Packages from top 25 of https://www.bioconductor.org/packages/stats/ Bioc <- c( "BiocInstaller", "BiocGenerics", "IRanges", "Biobase", "AnnotationDbi", "GenomeInfoDb", "S4Vectors", "zlibbioc", "Biostrings", "limma", "XVector", "GenomicRanges", "BiocParallel", "annotate", "Rsamtools", "genefilter", "rtracklayer", "biomaRt", "graph", "GenomicAlignments", "GenomicFeatures", "preprocessCore", "affy", "BSgenome", "geneplotter") suppressPackageStartupMessages(invisible(lapply(c(CRAN, Bioc), library, character.only = TRUE, quietly = TRUE))) all <- expand.grid(CRAN = CRAN, Bioconductor = Bioc, stringsAsFactors = FALSE) all$conflicts <- Map(conflicts2, all[[1]], all[[2]]) # Filter out all the generics defined in methods gen_defs <- function(namespace) { gens <- getGenerics(where=asNamespace(namespace)) Map(function(f, package) get(f, envir = asNamespace(package), mode = "function"), gens@.Data, gens@package) } filter_defs <- c(gen_defs("methods"), gen_defs("BiocGenerics")) in_defs <- function(x, defs) { any(as.logical( lapply(defs, function(xx) { identical(xx, x) || .hasSlot(xx, "default") && identical(xx@default@.Data, x) }))) } filter_methods <- function(x, package) { if (!length(x)) return(x) funs <- lapply(x, get, envir = asNamespace(package), mode = "function") in_methods <- vapply(funs, in_defs, logical(1), defs = filter_defs) x[!in_methods] } all$conflicts <- Map(filter_methods, all$conflicts, all$CRAN) all$`S3 Generics` <- Map(function(package, funs) Filter(function(x) pryr:::is_s3_generic(x, env = asNamespace(package)), funs), all$CRAN, all$conflicts) all$`S4 Generics` <- Map(function(package, funs) Filter(function(x) isGeneric(x, where = asNamespace(package)), funs), all$CRAN, all$conflicts) all$normal <- Map(function(conflicts, S3, S4) conflicts[!(conflicts %in% S3 | conflicts %in% S4)], all$conflicts, all$`S3 Generics`, all$`S4 Generics`) res <- all[lengths(all$conflicts) > 0, ] knitr::kable(res, row.names = FALSE)
library(tidyr) res2 <- unique(unnest(res, conflicts)[c("CRAN", "conflicts")]) res3 <- spread(res2, conflicts, CRAN, fill="") res4 <- lapply(res3, function(x) x[x != ""]) do.call(`cat`, c(Map(function(nme, pkgs) { paste0(" - ", nme, " - ", paste0(pkgs, collapse = ", ")) }, names(res4), res4, USE.NAMES = FALSE), list(sep = "\n")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.