title: Problem in R-markdown to pdf_document2 on using ggVennDiagram: cache conflict?
body: <p>I have recently made the addition of Venn-diagrams in my document using ggVennDiagram, which facilitates its arrangement with other ggplot2 objects.</p>
  <p>The thing is, now whenever I knit the file I encounter this error/warning and R gets stuck:</p>
  <p>&quot;Found more than one class &quot;Polygon&quot; in cache; using the first, from namespace 'sp'
  Also defined by 'ggVennDiagram'.</p>
  <p>I have tried unloading those packages that may use sp, the thing is, this package does not get loaded at all in my code and it appears not to be a dependency for the other packages.</p>
  <p>Does anyone have an idea on how to solve this?</p>
  <p>Thank you</p>
  <p>P.S.: I feel this may be enough for the question, but let me know if you need more. Just to clarify, I am using the following packages:</p>
  <p>&quot;tidyverse&quot;, &quot;reshape2&quot;, &quot;readxl&quot;, &quot;knitr&quot;, &quot;adegenet&quot;, &quot;poppr&quot;, &quot;pegas&quot;, &quot;ape&quot;, &quot;ggOceanMaps&quot;, &quot;RColorBrewer&quot;, &quot;lattice&quot;, &quot;viridisLite&quot;, &quot;pcadapt&quot;, &quot;colorBlindness&quot;, &quot;here&quot;, &quot;diveRsity&quot;, &quot;ggpubr&quot;, &quot;vcfR&quot;, &quot;MCMCpack&quot;, &quot;maps&quot;, &quot;kableExtra&quot;, &quot;ggnewscale&quot;)</p>
  <p>Here is an example in Rmd:</p>
  <pre><code>---
  title: &quot;Cache issue&quot;
  author: &quot;Estevez-Barcia, Daniel&quot;
  output:
    bookdown::pdf_document2:
      fig_crop: no
  header-includes:
   \usepackage{float}
   \floatplacement{table}{H}
   \floatplacement{figure}{H}
   \newcommand{\beginsupplement}{\setcounter{table}{0}  \renewcommand{\thetable}{S\arabic{table}} \setcounter{figure}{0} \renewcommand{\thefigure}{S\arabic{figure}}}
  ---
  
  ```{r setup}
  #| include=FALSE
  
  knitr::opts_chunk$set(echo = TRUE, # set up the default params for chunks
                        fig.pos = &quot;H&quot;,
                        fig.width= 8,
                        fig.height= 7,
                        tab.pos = &quot;H&quot;,
                        collapse = TRUE,
                        message = FALSE,
                        warning = FALSE,
                        comment = &quot;#&gt;&quot;
  )
  
  knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file()) # specify the project root to take files
  options(knitr.kable.NA = &quot;---&quot;) # change the NA in kable tables for ---
  ```
  
  ```{r load-first}
  #| include=FALSE, 
  #| echo=FALSE
  
  ## Packages to load and other characteristics
  
  packages &lt;- c(&quot;tidyverse&quot;, &quot;reshape2&quot;, &quot;readxl&quot;, &quot;knitr&quot;, &quot;adegenet&quot;, &quot;poppr&quot;, 
                &quot;pegas&quot;, &quot;ape&quot;, &quot;ggOceanMaps&quot;, &quot;RColorBrewer&quot;, &quot;lattice&quot;, &quot;viridisLite&quot;, 
                &quot;pcadapt&quot;, &quot;colorBlindness&quot;, &quot;here&quot;, &quot;diveRsity&quot;, &quot;ggpubr&quot;, &quot;vcfR&quot;, &quot;MCMCpack&quot;, 
                &quot;maps&quot;, &quot;kableExtra&quot;, &quot;ggnewscale&quot;)
  
  installed_packages &lt;- packages %in% rownames(installed.packages())
  if (any(installed_packages == FALSE)) {
    install.packages(packages[!installed_packages])
  }
  
  invisible(lapply(packages, library, character.only = TRUE))
  
  # Set custom theme for ggplot
  ggtheme = theme(axis.text.y = element_text(colour=&quot;black&quot;, size=12),
                  axis.text.x = element_text(colour=&quot;black&quot;, size=12, angle = 90),
                  axis.title = element_text(colour=&quot;black&quot;, size=12),
                  panel.border = element_rect(colour=&quot;black&quot;, fill=NA, size=1),
                  panel.background = element_blank(),
                  plot.title = element_text(hjust=0.5, size=15) 
  )
  
  # Additional libraries
  
  library(cowplot)
  library(grid)
  library(gridExtra)
  library(hierfstat)
  
  ```
  
  ```{r venn-diagram}
  #| echo=FALSE,
  #| include= FALSE
  
  randomPlot &lt;- ggplot(data = mtcars, aes(x = mpg, y = drat, color = cyl)) +
    geom_point()
  
  a &lt;- c(&quot;Ramón&quot;, &quot;Marta&quot;, &quot;Inés&quot;, &quot;John&quot;, &quot;Michael&quot;, &quot;Diego&quot;, &quot;Carmen&quot;, &quot;Aidara&quot;, &quot;Sofía&quot;)
  b &lt;- c(&quot;Ramón&quot;, &quot;Marta&quot;, &quot;Pablo&quot;, &quot;Paloma&quot;, &quot;Einar&quot;, &quot;Lykke&quot;, &quot;Carmen&quot;, &quot;Ester&quot;, &quot;Sofía&quot;, &quot;Knute&quot;)
  ggVenn &lt;- ggVennDiagram::ggVennDiagram(x = list(a, b), label_alpha = 0,
                category.names = c(&quot;Names1&quot;, &quot;Names2&quot;), label = &quot;count&quot;) +
    theme(legend.position = &quot;none&quot;)
  ```
  
  ```{r quick map}
  #| echo=FALSE
  
  dt &lt;- data.frame(lon = c(-30, -30, 30, 30), lat = c(50, 80, 80, 50))
  basemap(data = dt, bathymetry = TRUE) + 
    geom_polygon(data = transform_coord(dt), aes(x = lon, y = lat), color = &quot;red&quot;, fill = NA)
    
  ```
  
  ```{r plot}
  #| echo=FALSE
  
  ggarrange(randomPlot, ggVenn, nrow = 2)
  ```
  </code></pre>