<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/suggests-and-vignettes/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.enchufa2.es/archives/suggests-and-vignettes.html"> R – Enchufa2</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Dirk Eddelbuettel quite rightly reminded us the other day that <a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/blog/2017/03/22/#suggests_is_not_depends"><code>Suggests</code> is not <code>Depends</code></a>. I am sorry to say that I am one of those who are using <code>Suggests</code>… “casually”. <em>Mea culpa</em>. I must say that this is restricted to vignettes: there are no tests nor examples using suggested packages. But I am not checking if my suggested packages are available at all, which is definitely wrong. And I understand that it must be frustrating to run reverse dependencies on a package as popular as <code>Rcpp</code> when the rest of us are using <code>Suggests</code> so… casually. So I was definitely determined to solve this, and I finally managed to find a very simple solution that may be helpful to other maintainers.</p>
<p>Our <a target="_blank" rel="nofollow" href="https://cran.r-project.org/package=simmer"><code>simmer</code></a> package has seven vignettes. Two of them are very introductory and do not use any external package. But as you try to demonstrate more advanced features and use cases, you start needing some other tools; and their use could be intensive, so that checking suggested packages for every call or every code chunk might not scale. However, I realised that the important thing for those advanced vignettes is just to make the story they tell available to your users, and anyway they are always built and available online on CRAN. Therefore, I decided to add the following at the beginning of each vignette:</p>
<pre><code><span>required</span> <span>&lt;-</span> <span>c</span><span>(</span><span>&quot;pkg1&quot;</span>, <span>&quot;pkg2&quot;</span>, <span>&quot;pkgn&quot;</span><span>)</span>

<span>if</span> <span>(</span><span>!</span><span>all</span><span>(</span><span>unlist</span><span>(</span><span>lapply</span><span>(</span><span>required</span>, <span>function</span><span>(</span><span>pkg</span><span>)</span> <span>requireNamespace</span><span>(</span><span>pkg</span>, <span>quietly</span> <span>=</span> <span>TRUE</span><span>)</span><span>)</span><span>)</span><span>)</span><span>)</span>
  <span>knitr</span><span>:</span><span>:</span><span>opts_chunk</span><span>$</span><span>set</span><span>(</span><span>eval</span> <span>=</span> <span>FALSE</span><span>)</span></code></pre>
<p>Problem solved. Yes, I know, I am still taking <code>knitr</code> for granted. But given that it has its own entry (<code>VignetteBuilder</code>) in the <code>DESCRIPTION</code>, I think this is fair enough. I only hope that Dirk will unblacklist <code>simmer</code> after our next release. <img alt="😉" class="wp-smiley" src="https://s.w.org/images/core/emoji/2/72x72/1f609.png"></p>
<p><strong>Contenido extraído de Enchufa2.es</strong>: <a target="_blank" rel="nofollow" href="https://www.enchufa2.es/archives/suggests-and-vignettes.html">Suggests and Vignettes</a>.</p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://www.enchufa2.es/archives/suggests-and-vignettes.html"> R – Enchufa2</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/W2pfRVIju6E"></a></div>