<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:media="http://search.yahoo.com/mrss/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     version="2.0">
<channel>
<title>Christophe Dervieux</title>
<link>https://cderv.dev/index.html</link>
<atom:link href="https://cderv.dev/index.xml" rel="self" type="application/rss+xml"/>
<description>Notes on Quarto, R Markdown, and working with AI agents.</description>
<generator>quarto-2</generator>
<lastBuildDate>Mon, 25 Apr 2022 00:00:00 +0000</lastBuildDate>
<item>
<title>Updating existing tools in Github-hosted runners on GHA</title>
<link>https://cderv.dev/posts/2022-04-25-updating-gha-tools/index.html</link>
<description><![CDATA[




<section class="section level1" id="some-context-about-the-problem">
<h1>Some context about the problem</h1>
<p>Recently, I have been working on migrating our workflows for TinyTeX bundles released on <a href="https://github.com/yihui/tinytex-releases">tinytex-releases</a> from Appveyor to Github Action<span id="fnref1"><sup>1</sup></span>.</p>
<p>For adapting the workflow, I needed to easily create and update release from the workflow itself. Github CLI tool (<a class="uri" href="https://cli.github.com/">https://cli.github.com/</a>) comes in handy for such tasks, like managing Github Releases using <code>gh release</code> or making request with Github API using <code>gh api</code> . Github CLI is part of the pre-installed tools one can found in github-hosted runners.<span id="fnref2"><sup>2</sup></span> So it means you don’t have to install it in a workflow step.</p>
<p>While I was in the process of updating the workflows, it happens that a new release of the CLI went out and I was really waiting for it: <code>gh</code> version 2.8 adds a new <code>gh release edit</code> command that, among other things, allows to undraft an existing draft. That was the missing piece I needed to avoid some weird API calls as workaround.</p>
<p>However, I found out that github-hosted runners does not get updated right away with latest version- <code>gh</code> version 2.7 was still the one available by default.</p>
<p>That’s too bad - I really want to use the last version and don’t want to wait!</p>
</section>
<section class="section level1" id="updating-a-pre-installed-software">
<h1>Updating a pre-installed software</h1>
<p>So in order to use the last new release, I needed to find a way to update the existing one. Here are two solutions with examples for <code>unbuntu-latest</code> runners</p>
<section class="section level2" id="install-a-newer-version-using-brew">
<h2 class="anchored" data-anchor-id="install-a-newer-version-using-brew">Install a newer version using <code>brew</code></h2>
<p><code>brew</code> package manager has been already updated so <code>brew install gh</code> could be used. The important pieces are:</p>
<ul>
<li>Default <code>gh</code> is not install with <code>brew</code> so <code>brew update gh</code> won’t work</li>
<li><code>brew update</code> needs to be run for the runner to have the info about the new version</li>
<li>Specific <code>brew</code> binary <code>gh</code> needs to be used, located in <code>$(brew --prefix gh)/bin/gh</code></li>
</ul>
<p>Example in workflow file</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode yaml"><code class="sourceCode yaml">    <span class="hl-property">steps</span><span class="hl-punctuation-delimiter">:</span>      
      <span class="hl-comment"># this uses version 2.7</span>
      <span class="hl-punctuation-delimiter">-</span> <span class="hl-property">run</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">gh --version</span>
        
      <span class="hl-comment"># installing new version 2.8</span>
      <span class="hl-punctuation-delimiter">-</span> <span class="hl-property">name</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">update</span>
        <span class="hl-property">run</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-punctuation-delimiter">|</span><span class="hl-string">
          brew update
          brew install gh</span>
        
      <span class="hl-comment"># still point to version 2.7</span>
      <span class="hl-punctuation-delimiter">-</span> <span class="hl-property">run</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">which gh</span>
      
      <span class="hl-comment"># this using version 2.8</span>
      <span class="hl-punctuation-delimiter">-</span> <span class="hl-property">run</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">$(brew --prefix gh)/bin/gh --version</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
</section>
<section class="section level2" id="updating-the-included-version-using-a-.deb-file">
<h2 class="anchored" data-anchor-id="updating-the-included-version-using-a-.deb-file">Updating the included version using a <code>.deb</code> file</h2>
<p>Github CLI is released on <a class="uri" href="https://github.com/cli/cli">https://github.com/cli/cli</a> as a Github release. This means it is really easy to download a release bundle:</p>
<ul>
<li><p>Using available <code>gh</code> CLI directly</p>
</li>
<li><p>Specifying <code>-R</code> option to target CLI repo</p>
</li>
<li><p>Specificying <code>--pattern</code> to target which release asset to download. Example for <code>ubuntu-latest</code></p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="hl-function">gh</span> release download <span class="hl-constant">-R</span> cli/cli <span class="hl-constant">--pattern</span> <span class="hl-string">'*linux_amd64.deb'</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>The <code>pattern</code> needs to be adjusted according to the OS.</p>
</li>
</ul>
<p>Then it can be installed on the system, which will replace the pre-installed version</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="hl-function">sudo</span> dpkg <span class="hl-constant">-i</span> <span class="hl-string">'gh_2.8.0_linux_amd64.deb'</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>Here is a complete example in a workflow file</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode yaml"><code class="sourceCode yaml">    <span class="hl-property">steps</span><span class="hl-punctuation-delimiter">:</span>
      <span class="hl-comment"># this is 2.7 version</span>
      <span class="hl-punctuation-delimiter">-</span> <span class="hl-property">run</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">gh --version</span>
      
      <span class="hl-comment"># Updating and downloading the release</span>
      <span class="hl-punctuation-delimiter">-</span> <span class="hl-property">name</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">update</span>
        <span class="hl-property">env</span><span class="hl-punctuation-delimiter">:</span>
          <span class="hl-comment"># Needed for gh CLI to work</span>
          <span class="hl-property">GH_TOKEN</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">${{ secrets.GITHUB_TOKEN }}</span>
        <span class="hl-property">run</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-punctuation-delimiter">|</span><span class="hl-string">
          gh release download -R cli/cli --pattern '*linux_amd64.deb'
          sudo dpkg -i $(ls *.deb)</span>
      
      <span class="hl-comment"># same binary as 2.7</span>
      <span class="hl-punctuation-delimiter">-</span> <span class="hl-property">run</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">which gh</span>
      
      <span class="hl-comment"># now updated to 2.8</span>
      <span class="hl-punctuation-delimiter">-</span> <span class="hl-property">run</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">gh --version</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
</section>
</section>
<section class="section level1" id="conclusion">
<h1>Conclusion</h1>
<p>I ended using the second solution adding the update step in my workflow. Obviously, this can be removed when <code>gh</code> 2.8 will be available on the runners.</p>
<p>This post will be useful for future me maybe so that I don’t search again for this. But maybe it can be useful to someone else… that is why it is best to go public with notes, right ?</p>
</section>
<div class="default" id="quarto-appendix">
<section class="footnotes section" id="footnotes" role="doc-endnotes">
<h2 class="anchored quarto-appendix-heading" data-anchor-id="footnotes">Footnotes</h2>
<ol type="1">
<li><div id="fn1">
<p>And more exactly these PR <a href="https://github.com/yihui/tinytex/pull/362">yihui/tinytex#362</a>, <a href="https://github.com/yihui/tinytex/pull/369">yihui/tinytex#369</a> and <a href="https://github.com/yihui/tinytex-releases/pull/22">yihui/tinytex-releases#22</a>.↩︎</p>
</div>
</li>
<li><div id="fn2">
<p>You can find about supported sofware in github-hosted runners in the doc for each OS at <a class="uri" href="https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software">https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software</a>↩︎</p>
</div>
</li>
</ol>
</section>
</div>

]]></description>
<category>tips</category>
<category>gha</category>
<guid>https://cderv.dev/posts/2022-04-25-updating-gha-tools/index.html</guid>
<pubDate>Mon, 25 Apr 2022 00:00:00 +0000</pubDate>
</item>
<item>
<title>Signed git commit with Keybase and Gpg on Windows 10</title>
<link>https://cderv.dev/posts/2021-10-11-signed-git-commit-with-keybase-and-gpg-on-windows-10/index.html</link>
<description><![CDATA[




<p>Signing git commit is something that I have already done in the past following Github Documentation. However, last week I stumble upon Garrick’s post “<a href="https://www.garrickadenbuie.com/blog/signed-verified-git-commits-keybase-rstudio/">Signed and verified: signed git commits with Keybase and RStudio</a>” which explains how to use Keybase for signing commit for Mac OS. As often, following a tutorial for Windows user is not as easy. This post is about the step I used to make it happen on Windows 10. It is mainly a resource for my future self but it may be useful to other too.</p>
<section class="section level2" id="about-the-tooling">
<h2 class="anchored" data-anchor-id="about-the-tooling">About the tooling</h2>
<p>I am working on Windows 10 and using Powershell 7 in Windows Terminal for most of my CLI task.</p>
<p>If you are trying to setup all this in WSL, following Garrick’s post should work fine as it is linux based.</p>
<section class="section level3" id="gpg-on-a-windows-10-computer">
<h3 class="anchored" data-anchor-id="gpg-on-a-windows-10-computer">Gpg on a Windows 10 computer</h3>
<p>After several tries, I think the best working tool is <em>Gpg4Win</em> . As I used <em>winget</em> (and <em>scoop</em>) as package manager, I installed it using</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode powershell"><code class="sourceCode powershell">winget install gpg4win -i</code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>I used <code>-i</code> flag for triggering interactive installation to unselect installation of Outlook and IE pluggins which I don’t use. Aim is to only install Gpg and Kleopatra (GUI on Windows for GPG).</p>
<p>If you don’t use a package manager, you can also download directly from <a class="uri" href="https://www.gpg4win.org/">https://www.gpg4win.org/</a></p>
</section>
<section class="section level3" id="keybase-for-managing-identities">
<h3 class="anchored" data-anchor-id="keybase-for-managing-identities">Keybase for managing identities</h3>
<p>Keybase (<a class="uri" href="https://keybase.io/">https://keybase.io/</a>) is a “a <a href="https://en.wikipedia.org/wiki/Key_server_(cryptographic">key directory</a>”Key server (cryptographic)“) that maps <a href="https://en.wikipedia.org/wiki/Social_media" title="Social media">social media</a> identities to encryption keys (including, but not limited to <a href="https://en.wikipedia.org/wiki/Pretty_Good_Privacy" title="Pretty Good Privacy">PGP</a> keys) in a publicly auditable manner.”<span id="fnref1"><sup>1</sup></span></p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode powershell"><code class="sourceCode powershell">winget install keybase</code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>After that you can follow Garrick’s blog post</p>
<section class="section level4" id="creating-gpg-pgp-key">
<h4 class="anchored" data-anchor-id="creating-gpg-pgp-key">Creating GPG / PGP key</h4>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode powershell"><code class="sourceCode powershell">keybase pgp gen --multi</code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>This will run gpg for you to store the private key. Enter a passphrase.</p>
<p>If you open <em>kleopatra</em> GUI, you’ll see the new created GPG key in your keychain.<br>If you open <em>keybase</em> GUI, you’ll see the registered PGP key in your identities.</p>
</section>
</section>
<section class="section level3" id="setting-up-in-git">
<h3 class="anchored" data-anchor-id="setting-up-in-git">Setting up in Git</h3>
<p>Follow <a href="https://www.ankursheel.com/blog/securing-git-commits-windows">A guide to securing git commits from tricking you on Windows</a></p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode powershell"><code class="sourceCode powershell"># Tell Git to use the key
git config --global user.signingkey &lt;keyid&gt;
# Tell Git to sign commit by default
git config --global commit.gpgsign true
# Tell Git to sign tags by default
git config --global tag.gpgsign true
# Tell Git to use the gpg program from gpg4win
git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe"</code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
</section>
<section class="section level3" id="add-your-key-to-github">
<h3 class="anchored" data-anchor-id="add-your-key-to-github"><strong>Add your key to GitHub</strong></h3>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode powershell"><code class="sourceCode powershell">keybase pgp export -q &lt;keyid&gt; | Set-Clipboard</code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>And paste it in <a href="https://github.com/settings/keys">github.com/settings/keys</a> when creating a New GPG key.</p>
</section>
<section class="section level3" id="start-gpg-agent-on-windows-startup">
<h3 class="anchored" data-anchor-id="start-gpg-agent-on-windows-startup">Start GPG agent on Windows startup</h3>
<p><code>gpg-agent</code> will be used by Git to sign the commit by opening a window to enter your passphrase. I am not sure why this process does not start on windows startup unfortunately. You’ll need to manually add it to startup program.</p>
<p>Following this resource is easy enough <a href="https://gist.github.com/matusnovak/302c7b003043849337f94518a71df777#start-the-agent-on-startup">GPG on Windows - Start the agent on startup</a></p>
</section>
<section class="section level3" id="resources">
<h3 class="anchored" data-anchor-id="resources">Resources</h3>
<ul>
<li><p><a href="https://www.garrickadenbuie.com/blog/signed-verified-git-commits-keybase-rstudio/#fn3">https://www.garrickadenbuie.com/blog/signed-verified-git-commits-keybase-rstudio/</a></p>
</li>
<li><p><a class="uri" href="https://www.gpg4win.org/about.html">https://www.gpg4win.org/about.html</a></p>
</li>
<li><p><a class="uri" href="https://www.ankursheel.com/blog/securing-git-commits-windows">https://www.ankursheel.com/blog/securing-git-commits-windows</a></p>
</li>
<li><p><a href="https://medium.com/@roneythomas/keybase-io-gpg-git-signing-on-windows-456cddde4a48">https://medium.com/@roneythomas/keybase-io-gpg-git-signing-on-windows-456cddde4a48</a></p>
</li>
<li><p><a class="uri" href="https://docs.github.com/en/authentication/managing-commit-signature-verification/adding-a-new-gpg-key-to-your-github-account">https://docs.github.com/en/authentication/managing-commit-signature-verification/adding-a-new-gpg-key-to-your-github-account</a></p>
</li>
</ul>
</section>
</section>
<div class="default" id="quarto-appendix">
<section class="footnotes section" id="footnotes" role="doc-endnotes">
<h2 class="anchored quarto-appendix-heading" data-anchor-id="footnotes">Footnotes</h2>
<ol type="1">
<li><div id="fn1">
<p><a class="uri" href="https://en.wikipedia.org/wiki/Keybase">https://en.wikipedia.org/wiki/Keybase</a>↩︎</p>
</div>
</li>
</ol>
</section>
</div>

]]></description>
<category>windows</category>
<category>security</category>
<guid>https://cderv.dev/posts/2021-10-11-signed-git-commit-with-keybase-and-gpg-on-windows-10/index.html</guid>
<pubDate>Mon, 11 Oct 2021 00:00:00 +0000</pubDate>
</item>
<item>
<title>Retrieve all fig.alt in a single appendix</title>
<link>https://cderv.dev/posts/2021-06-29-fig-alt-appendix/index.html</link>
<description><![CDATA[




<!--
Ported from the Hugo/blogdown blog with frozen outputs: R code is not
executed. Example files, the embedded tweets and the rendered screenshot
(output.png) were copied from the blogdown-rendered index.html of the old
post; the SCSS/CSS chunks are inlined as their compiled CSS.
-->
<style type="text/css">
pre.yaml{margin:0px;padding-bottom:0px;border-bottom-style:none}pre.yaml code{padding-bottom:0px}pre.yaml+pre.md,pre.yaml+pre.markdown{border-top-style:none;padding-top:0px}pre.yaml+pre.md code,pre.yaml+pre.markdown code{padding-top:0px}
img.embeded-rmd {
  border-style: solid;
  border-color: grey;
}
</style>
<script src="widgets.js"></script>
<p>Recently, I was pinged on Twitter about a ‘How to’ with <strong>rmarkdown</strong> and <strong>knitr</strong></p>
<blockquote align="center" class="twitter-tweet" data-dnt="true" data-lang="en" data-theme="light" data-width="550"><p dir="ltr" lang="en">Is there an existing function/structure to scrape the alt-text from knitr chunks in an Rmd?<br>I want to collate the descriptions for an appendix for the pdf rendering.<a href="https://twitter.com/hashtag/Rstats?src=hash&amp;ref_src=twsrc%5Etfw">#Rstats</a> <a href="https://twitter.com/rstudio?ref_src=twsrc%5Etfw">@Rstudio</a></p>— Dr Simonis (they/them) knows what chem weapons are (@JuniperLSimonis) <a href="https://twitter.com/JuniperLSimonis/status/1408886794297307137?ref_src=twsrc%5Etfw">June 26, 2021</a></blockquote>

<blockquote align="center" class="twitter-tweet" data-conversation="none" data-dnt="true" data-lang="en" data-theme="light" data-width="550"><p dir="ltr" lang="en">Right, yes, those parts of knitr look very complicated to me! Perhaps <a href="https://twitter.com/apreshill?ref_src=twsrc%5Etfw">@apreshill</a> <a href="https://twitter.com/chrisderv?ref_src=twsrc%5Etfw">@chrisderv</a> and <a href="https://twitter.com/xieyihui?ref_src=twsrc%5Etfw">@xieyihui</a> could guide us on how to make that work for the alt text also.</p>— Ben Marwick (@benmarwick) <a href="https://twitter.com/benmarwick/status/1408910726580736000?ref_src=twsrc%5Etfw">June 26, 2021</a></blockquote>
<p>The idea is simple:</p>
<div class="center" style="text-align:center">
<p>Can we retrieve all alternative texts set with <code>fig.alt</code> chunk option<span id="fnref1"><sup>1</sup></span> to display them in an appendix at the end of the document ?</p>
</div>
<p>There is not a straightforward way but using a few <strong>knitr</strong> tricks, this can be done. Let’s take this small example file:</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode yaml"><code class="sourceCode yaml"><span class="hl-punctuation-special">---</span>
<span class="hl-property">title</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">Retrieving fig.alt in appendix</span>
<span class="hl-property">output</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">html_document</span>
<span class="hl-punctuation-special">---</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode markdown"><code class="sourceCode markdown">
<span class="hl-punctuation-special">#</span><span class="hl-markup-heading"> A simple plot
</span>
<span class="hl-punctuation-delimiter">```</span><span class="hl-attribute">{r </span><span class="hl-label">simple-plot</span><span class="hl-attribute">, fig.alt = "A simple plot with dots", echo = FALSE}</span>
plot(1:10)
<span class="hl-punctuation-delimiter">```</span>

# Another one

```{r cars-speed, fig.alt = "A plot about cars' stopping speed vs distance", echo = FALSE}
plot(cars)
<span class="hl-punctuation-delimiter">```</span>
<span class="hl-punctuation-special">#</span><span class="hl-markup-heading"> some other content
</span>
<span class="hl-punctuation-delimiter">```</span><span class="hl-attribute">{r}</span>
<span class="hl-number">1</span><span class="hl-operator">+</span><span class="hl-number">1</span>
<span class="hl-punctuation-delimiter">```</span>

<span class="hl-punctuation-special">#</span><span class="hl-markup-heading"> Appendix
</span>
Here are all the alt text set for previous figures
</code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>We would like to retrieve all the <code>fig.alt</code> set at the end of the document as a bullet point list. This can be done using advanced knitr features:</p>
<ul>
<li><code>knitr::all_labels()</code> which allows to retrieve all chunk labels in a document. You can find a usage example in the R Markdown Cookbook about how to <a href="https://bookdown.org/yihui/rmarkdown-cookbook/code-appendix.html#code-appendix">Put together all code in the appendix</a></li>
<li><code>knitr::knit_code</code> which allows to retrieve code content from any chunk using its labels. The object return contains chunk options in attributes. This <a href="https://emitanaka.rbind.io/post/knitr-knitr-code/">post by Emi Tanaka</a> gives a nice introduction on what this can do. This is a really advanced feature to use with caution. See at leas <code>?knitr::knit_code</code> before using it!</li>
<li><code>result='asis'</code> and <code>knitr::knit_expand()</code> <a href="https://bookdown.org/yihui/rmarkdown-cookbook/knit-expand.html">to generate Rmd source from variable</a>.</li>
</ul>
<p>Putting this together, we would do first</p>
<ul>
<li>Retrieve the chunks with a <code>fig.alt</code> labels</li>
<li>Retrieve the options set on these chunks to get the <code>fig.alt</code> one</li>
</ul>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode r"><code class="sourceCode r"><span class="hl-comment"># get all labels from chunk with fig.alt chunk option defined</span>
<span class="hl-variable">chunks_with_alt</span> <span class="hl-operator">&lt;-</span> <span class="hl-namespace">knitr</span><span class="hl-operator">::</span><span class="hl-function">all_labels</span><span class="hl-punctuation-bracket">(</span><span class="hl-function">nzchar</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">fig.alt</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span>
<span class="hl-comment"># Use these labels to retrieve code content </span>
<span class="hl-variable">chunks_content</span> <span class="hl-operator">&lt;-</span> <span class="hl-namespace">knitr</span><span class="hl-operator">::</span><span class="hl-variable">knit_code</span><span class="hl-operator">$</span><span class="hl-variable">get</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">chunks_with_alt</span><span class="hl-punctuation-bracket">)</span>
<span class="hl-comment"># retrieve specifically chunk options</span>
<span class="hl-variable">chunks_opts</span> <span class="hl-operator">&lt;-</span> <span class="hl-function">lapply</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">chunks_content</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-keyword-function">function</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">x</span><span class="hl-punctuation-bracket">)</span> <span class="hl-function">attr</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">x</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-string">"chunk_opts"</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>Then we would write our markdown content, for example using <code>knitr::knit_expand</code> as templating mechanism. We want something like this in markdown to obtain a list in HTML</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode markdown"><code class="sourceCode markdown"><span class="hl-punctuation-special">* </span>Figure 1 (chunk label 'plot-1): An alt text</code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>This would be generated by looping on selected chunk option to create these markdown strings.</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode r"><code class="sourceCode r"><span class="hl-comment"># Looping over the selected chunks</span>
<span class="hl-variable">l</span> <span class="hl-operator">&lt;-</span> <span class="hl-function">lapply</span><span class="hl-punctuation-bracket">(</span><span class="hl-function">seq_along</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">chunks_opts</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-keyword-function">function</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">opt_ind</span><span class="hl-punctuation-bracket">)</span> <span class="hl-punctuation-bracket">{</span>
  <span class="hl-comment"># We use the index number but we need the option content</span>
  <span class="hl-variable">opt</span> <span class="hl-operator">&lt;-</span> <span class="hl-variable">chunks_opts</span><span class="hl-punctuation-bracket">[[</span><span class="hl-variable">opt_ind</span><span class="hl-punctuation-bracket">]]</span>
  <span class="hl-namespace">knitr</span><span class="hl-operator">::</span><span class="hl-function">knit_expand</span><span class="hl-punctuation-bracket">(</span>
    <span class="hl-comment"># template string to fill in using index...</span>
    <span class="hl-variable-parameter">text</span> <span class="hl-operator">=</span> <span class="hl-string">"* Figure {{opt_ind}} (chunk label '{{label}}'): {{alt_text}}"</span><span class="hl-punctuation-delimiter">,</span> 
    <span class="hl-comment"># and the alt text set...</span>
    <span class="hl-variable-parameter">alt_text</span> <span class="hl-operator">=</span> <span class="hl-variable">opt</span><span class="hl-operator">$</span><span class="hl-variable">fig.alt</span><span class="hl-punctuation-delimiter">,</span>
    <span class="hl-comment"># and the label of the chunk</span>
    <span class="hl-variable-parameter">label</span> <span class="hl-operator">=</span> <span class="hl-variable">opt</span><span class="hl-operator">$</span><span class="hl-variable">label</span><span class="hl-punctuation-bracket">)</span>
<span class="hl-punctuation-bracket">}</span><span class="hl-punctuation-bracket">)</span>
<span class="hl-comment"># Using cat() to output the string content to be included as-is.</span>
<span class="hl-function">cat</span><span class="hl-punctuation-bracket">(</span><span class="hl-function">unlist</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">l</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-variable-parameter">sep</span> <span class="hl-operator">=</span> <span class="hl-string">"</span><span class="hl-string-escape">\n</span><span class="hl-string">"</span><span class="hl-punctuation-bracket">)</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>The code above could be included in a single Rmd document like this, using the correct chunk option to hide the code and output the markdown strings as is.</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode yaml"><code class="sourceCode yaml"><span class="hl-punctuation-special">---</span>
<span class="hl-property">title</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">Retrieving fig.alt in appendix</span>
<span class="hl-property">output</span><span class="hl-punctuation-delimiter">:</span> <span class="hl-string">html_document</span>
<span class="hl-punctuation-special">---</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode markdown"><code class="sourceCode markdown">
<span class="hl-punctuation-special">#</span><span class="hl-markup-heading"> A simple plot
</span>
<span class="hl-punctuation-delimiter">```</span><span class="hl-attribute">{r </span><span class="hl-label">simple-plot</span><span class="hl-attribute">, fig.alt = "A simple plot with dots", echo = FALSE}</span>
plot(1:10)
<span class="hl-punctuation-delimiter">```</span>

# Another one

```{r cars-speed, fig.alt = "A plot about cars' stopping speed vs distance", echo = FALSE}
plot(cars)
<span class="hl-punctuation-delimiter">```</span>

<span class="hl-punctuation-special">#</span><span class="hl-markup-heading"> some other content
</span>
<span class="hl-punctuation-delimiter">```</span><span class="hl-attribute">{r}</span>
<span class="hl-number">1</span><span class="hl-operator">+</span><span class="hl-number">1</span>
<span class="hl-punctuation-delimiter">```</span>

<span class="hl-punctuation-special">#</span><span class="hl-markup-heading"> Appendix
</span>
Here are all the alt text set for previous figures

<span class="hl-punctuation-delimiter">```</span><span class="hl-attribute">{r </span><span class="hl-label">retrieve-chunk-opt</span><span class="hl-attribute">, include= FALSE}</span>
<span class="hl-punctuation-special">#</span><span class="hl-markup-heading"> get all labels from chunk with fig.alt chunk option defined
</span>chunks_with_alt &lt;- knitr::all_labels(nzchar(fig.alt))
<span class="hl-punctuation-special">#</span><span class="hl-markup-heading"> Use these labels to retrieve code content 
</span>chunks_content &lt;- knitr::knit_code$get(chunks_with_alt)
# retrieve specifically chunk options
chunks_opts &lt;- lapply(chunks_content, function(x) attr(x, "chunk_opts"))
```

```{r write-appendix, results='asis', echo = FALSE}
# Looping over the selected chunks
l &lt;- lapply(seq_along(chunks_opts), function(opt_ind) {
  # We use the index number but we need the option content
  opt &lt;- chunks_opts[[opt_ind]]
  knitr::knit_expand(
    # template string to fill in using index...
    text = "* Figure {{opt_ind}} (chunk label '{{label}}'): {{alt_text}}", 
    # and the alt text set...
    alt_text = opt$fig.alt,
    # and the label of the chunk
    label = opt$label)
})
# Using cat() to output the string content to be included as-is.
cat(unlist(l), sep = "\n")
```</code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>After rendering, the resulting document would look like this</p>
<p><img alt="resulting html document with appendix" class="embeded-rmd img-fluid" src="https://cderv.dev/posts/2021-06-29-fig-alt-appendix/output.png" width="400"></p>
<img alt="R Markdown Cookbook cover image" data-external="1" src="https://bookdown.org/yihui/rmarkdown-cookbook/images/cover.png" style="width: 20%; padding: 0 15px; margin: 0 0; float: right;">
<p>This is a rather advanced solution using some of the less-known feature of <strong>knitr</strong>. I am sure there could also be another approach using the <a href="https://rundel.github.io/parsermd/"><strong>parsermd</strong></a> by <a href="https://github.com/rundel"><code>@rundel</code></a> which helps you parse a Rmd file, including chunk option. However, that would mean reading the Rmd file during rendering of the same Rmd file… but why not ! I let you try.</p>
<p>For more recipes about R Markdown, don’t forget to read the <a href="https://bookdown.org/yihui/rmarkdown-cookbook/">R Markdown Cookbook</a> from which some of the tricks here are based !</p>
<div class="default" id="quarto-appendix">
<section class="footnotes section" id="footnotes" role="doc-endnotes">
<h2 class="anchored quarto-appendix-heading" data-anchor-id="footnotes">Footnotes</h2>
<ol type="1">
<li><div id="fn1">
<p>If you are not familiar with this chunk option, this is a new one added in knitr 1.32 to set alternative text on any figures inside code chunk. More about it on the <a href="https://blog.rstudio.com/2021/04/20/knitr-fig-alt/">This blog post</a>.↩︎</p>
</div>
</li>
</ol>
</section>
</div>

]]></description>
<category>R</category>
<category>knitr</category>
<guid>https://cderv.dev/posts/2021-06-29-fig-alt-appendix/index.html</guid>
<pubDate>Tue, 29 Jun 2021 00:00:00 +0000</pubDate>
<media:content url="https://cderv.dev/posts/2021-06-29-fig-alt-appendix/output.png" medium="image" type="image/png" width="144" height="262"/>
</item>
<item>
<title>New (old) blog: Welcome!</title>
<link>https://cderv.dev/posts/2021-06-25-new-old-blog/index.html</link>
<description><![CDATA[




<section class="section level1" id="a-short-story">
<h1>A short story</h1>
<p>This is now real, I have officially make this blog no more “work in progress”.</p>
<p>I initially created this blog in 2017 to follow a trend on the R community to have a blog. At the time, I was trying to contribute to Open Source on my free time and thought it could be good thing to have my own website. <a href="https://support.rbind.io/about/">rbind.io</a> organization was also a good opportunity to have a website with a cool url quickly setup: https://cderv.rbind.io was created</p>
<p>Truth is…</p>
<p>This project was at the time a great opportunity to learn <a href="https://pkgs.rstudio.com/blogdown/"><strong>blogdown</strong></a>, learn <a href="https://gohugo.io/"><strong>Hugo</strong></a> and how to tweak themes and websites. It was beneficial to me for that matters.</p>
<p>But second truth is…</p>
<p>Blogging (writing) is not my thing! This is not an activity I was used too, and I dedicated my open source time to contribute in code source and issues, what I thought would directly help others. I always thought that I had nothing interesting enough to share. That is why since then, only 2 blog posts were published on the only two topics I convinced myself it was interesting to make public<span id="fnref1"><sup>1</sup></span>.</p>
</section>
<section class="section level1" id="so-what-has-changed">
<h1>So what has changed ?</h1>
<p>Since then, things happened…</p>
<p>I got more present in the R community, my contribution were welcomed and valued. I went to conferences, met some great people and learned a ton of stuff. I also evolved in my job and got more technical and more aligned with my interest in software development ecosystem<span id="fnref2"><sup>2</sup></span>. Part of my commitment<span id="fnref3"><sup>3</sup></span> on Open Source work was to help others and I answered a lot of issues and a lot of questions (A very good way to learn something by the way!). So I happen to know stuff, and people were more and more asking me questions. So among all the discussion I had, the topic of blogging was always coming up. My excuse of not having anything to talk about was not real:</p>
<blockquote>
<p>“You could just blog about all the answer you give online”</p>
<p>— <span class="citation" data-cites="almosteveryone">@almosteveryone</span></p>
</blockquote>
<p>Yes probably I could have done that. But at then that was not enough to get back to this website unfortunately.</p>
<p>So what has changed now ?</p>
<p>First, I was invited some times ago by Yihui Xie to coauthor a book on R Markdown. It seems he thought I was the right person to share some knowledge in his new book. It ended being the <a href="https://bookdown.org/yihui/rmarkdown-cookbook/">“The R Markdown Cookbook”</a> published<span id="fnref4"><sup>4</sup></span> in 2020. So first change: I started writing !</p>
<p>Then, since August 2020, I am now a Software Engineer at RStudio. I have the chance to dedicate my time directly on Open Source. I was selected among other candidates to join the R Markdown team with Yihui. What an opportunity ! And what a slap on the head</p>
<blockquote>
<p>You can’t say anymore that you have nothing to share. You know enough to be a software engineer in one of RStudio’s team! You surely have some things to share !<br>– Voice in my head</p>
</blockquote>
<p>So that was it<span id="fnref5"><sup>5</sup></span> !</p>
</section>
<section class="section level1" id="lets-make-this-blog-finally-live">
<h1>Let’s make this blog finally live!</h1>
<p>I am now in a great team and doing great things in the open. I should at least share my notes in the open and tell what I am doing and what I know.</p>
<p>So from now on, you could expect to see this blog having some new content. It will probably be:</p>
<ul>
<li>mainly short post. I like <a href="https://yihui.org/en/">Yihui’s blog</a> and Miles McBrain’s <a href="https://milesmcbain.micro.blog/">microblog</a> for that.</li>
<li>sharing answer and how-to I usually only leave on their Github Issues, or in Gists.</li>
<li>new stuff I may work on, because after I work on R Markdown and this is surely something that is not of interest to me only.</li>
<li>short stories maybe, because it seems writing is a good habit to be at peace. So why not.</li>
</ul>
<p>But hey, it could also be different! Only the future will let us know…</p>
<p>So Let’s start blogging on this new (old) blog! You are welcome to follow along with me!</p>
</section>
<div class="default" id="quarto-appendix">
<section class="footnotes section" id="footnotes" role="doc-endnotes">
<h2 class="anchored quarto-appendix-heading" data-anchor-id="footnotes">Footnotes</h2>
<ol type="1">
<li><div id="fn1">
<p>The 2019 RStudio Conf talk by David Robinson <a href="https://www.rstudio.com/resources/rstudioconf-2019/the-unreasonable-effectiveness-of-public-work/">“The Ureasonable Effectiveness of Public Work”</a> helped me on this consideration.↩︎</p>
</div>
</li>
<li><div id="fn2">
<p>More on my background in the <a href="https://cderv.dev/about.html">about page</a>↩︎</p>
</div>
</li>
<li><div id="fn3">
<p>which was only a commitment to myself toward the R community I wanted to give back to.↩︎</p>
</div>
</li>
<li><div id="fn4">
<p>published by <a href="https://www.routledge.com/p/book/9780367563837">Chapman &amp; Hall/CRC</a> and and licensed under the <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.↩︎</p>
</div>
</li>
<li><div id="fn5">
<p>I think I am also now at peace with myself that only interested people will read this blog and other won’t bother. Even it is for my future self, it is worth sharing in this site. right ?↩︎</p>
</div>
</li>
</ol>
</section>
</div>

]]></description>
<guid>https://cderv.dev/posts/2021-06-25-new-old-blog/index.html</guid>
<pubDate>Fri, 25 Jun 2021 00:00:00 +0000</pubDate>
</item>
<item>
<title>Looking for non english package in CRAN</title>
<link>https://cderv.dev/posts/2018-03-11-non-english-pkg-in-cran/index.html</link>
<description><![CDATA[




<!--
Ported from the Hugo/blogdown blog with frozen outputs: R code is not
executed. Printed output, tables and figures were copied from the
blogdown-rendered index.html and index_files/figure-html/ of the old post.
-->
<p>Trying to figure out how encoding work in 📦 for writing french DESCRIPTION and manual files, I was wondering if others packages on CRAN as been wrote in French or any other non english language.</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode r"><code class="sourceCode r"><span class="hl-function">library</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">tidyverse</span><span class="hl-punctuation-bracket">)</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<section class="section level1" id="looking-into-the-cran-database">
<h1>Looking into the cran database</h1>
<p>First, we load the cran database with all information about description fields. We keep only some fields that can helps us look for not english packages. (For a list of all the fields meaning, read <a href="https://cran.r-project.org/doc/manuals/r-release/R-exts.html#The-DESCRIPTION-file">Writing R Extensions</a>)</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode r"><code class="sourceCode r"><span class="hl-variable">to_keep</span>  <span class="hl-operator">&lt;-</span> <span class="hl-function">c</span><span class="hl-punctuation-bracket">(</span><span class="hl-string">"Package"</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-string">"Title"</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-string">"Description"</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-string">"Encoding"</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-string">"Language"</span><span class="hl-punctuation-bracket">)</span>
<span class="hl-variable">cran_db</span> <span class="hl-operator">&lt;-</span> <span class="hl-namespace">tools</span><span class="hl-operator">::</span><span class="hl-function">CRAN_package_db</span><span class="hl-punctuation-bracket">(</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">[</span><span class="hl-variable">to_keep</span><span class="hl-punctuation-bracket">]</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">as_tibble</span><span class="hl-punctuation-bracket">(</span><span class="hl-punctuation-bracket">)</span>
<span class="hl-function">glimpse</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">cran_db</span><span class="hl-punctuation-bracket">)</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<div class="code-copy-outer-scaffold">
<pre class="code-with-copy"><code>## Rows: 17,802
## Columns: 5
## $ Package     &lt;chr&gt; "A3", "aaSEA", "AATtools", "ABACUS", "abbyyR", "abc", "abc~
## $ Title       &lt;chr&gt; "Accurate, Adaptable, and Accessible Error Metrics for Pre~
## $ Description &lt;chr&gt; "Supplies tools for tabulating and analyzing the results o~
## $ Encoding    &lt;chr&gt; NA, "UTF-8", "UTF-8", "UTF-8", NA, NA, NA, "UTF-8", "UTF-8~
## $ Language    &lt;chr&gt; NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~</code></pre>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p>Let’s see how many package set their Encoding field in their DESCRIPTION</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode r"><code class="sourceCode r"><span class="hl-variable">nb_of_na</span> <span class="hl-operator">&lt;-</span> <span class="hl-variable">cran_db</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">filter</span><span class="hl-punctuation-bracket">(</span><span class="hl-function">is.na</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">Encoding</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">count</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">Encoding</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">pull</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">n</span><span class="hl-punctuation-bracket">)</span>
<span class="hl-function">ggplot</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">cran_db</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">filter</span><span class="hl-punctuation-bracket">(</span><span class="hl-operator">!</span><span class="hl-function">is.na</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">Encoding</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">geom_bar</span><span class="hl-punctuation-bracket">(</span><span class="hl-function">aes</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">x</span> <span class="hl-operator">=</span> <span class="hl-variable">Encoding</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-variable-parameter">fill</span> <span class="hl-operator">=</span> <span class="hl-string">"skyblue"</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">labs</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">title</span> <span class="hl-operator">=</span> <span class="hl-string">"Nb of package with Encoding field"</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-variable-parameter">subtitle</span> <span class="hl-operator">=</span> <span class="hl-namespace">glue</span><span class="hl-operator">::</span><span class="hl-function">glue</span><span class="hl-punctuation-bracket">(</span><span class="hl-string">"{nb_of_na} packages with unset Encoding field"</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">theme_light</span><span class="hl-punctuation-bracket">(</span><span class="hl-punctuation-bracket">)</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p><img alt="Bar chart: Nb of package with Encoding field" class="img-fluid" src="https://cderv.dev/posts/2018-03-11-non-english-pkg-in-cran/unnamed-chunk-3-1.png" width="672"></p>
<p>Is there any package that uses a Language field in their DESCRIPTION ?</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode r"><code class="sourceCode r"><span class="hl-variable">nb_of_na</span> <span class="hl-operator">&lt;-</span> <span class="hl-variable">cran_db</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">filter</span><span class="hl-punctuation-bracket">(</span><span class="hl-function">is.na</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">Language</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">count</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">Language</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">pull</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">n</span><span class="hl-punctuation-bracket">)</span>
<span class="hl-function">ggplot</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">cran_db</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">filter</span><span class="hl-punctuation-bracket">(</span><span class="hl-operator">!</span><span class="hl-function">is.na</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">Language</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">geom_bar</span><span class="hl-punctuation-bracket">(</span><span class="hl-function">aes</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">x</span> <span class="hl-operator">=</span> <span class="hl-variable">Language</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-variable-parameter">fill</span> <span class="hl-operator">=</span> <span class="hl-string">"skyblue"</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">labs</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">title</span> <span class="hl-operator">=</span> <span class="hl-string">"Nb of package with Language field"</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-variable-parameter">subtitle</span> <span class="hl-operator">=</span> <span class="hl-namespace">glue</span><span class="hl-operator">::</span><span class="hl-function">glue</span><span class="hl-punctuation-bracket">(</span><span class="hl-string">"{nb_of_na} packages with unset Language field"</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">coord_flip</span><span class="hl-punctuation-bracket">(</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">theme_light</span><span class="hl-punctuation-bracket">(</span><span class="hl-punctuation-bracket">)</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p><img alt="Bar chart: Nb of package with Language field" class="img-fluid" src="https://cderv.dev/posts/2018-03-11-non-english-pkg-in-cran/unnamed-chunk-4-1.png" width="672"></p>
<p>So there are some package that declares their Language field in the DESCRIPTION. These field means:</p>
<blockquote>
<p>A ‘Language’ field can be used to indicate if the package documentation is not in English: this should be a comma-separated list of standard (not private use or grandfathered) IETF language tags as currently defined by RFC 5646 (<a class="uri" href="https://tools.ietf.org/html/rfc5646">https://tools.ietf.org/html/rfc5646</a>, see also <a class="uri" href="https://en.wikipedia.org/wiki/IETF_language_tag">https://en.wikipedia.org/wiki/IETF_language_tag</a>), i.e., use language subtags which in essence are 2-letter ISO 639-1 (<a class="uri" href="https://en.wikipedia.org/wiki/ISO_639-1">https://en.wikipedia.org/wiki/ISO_639-1</a>) or 3-letter ISO 639-3 (<a class="uri" href="https://en.wikipedia.org/wiki/ISO_639-3">https://en.wikipedia.org/wiki/ISO_639-3</a>) language codes.</p>
</blockquote>
<p>Which are those packages ?</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode r"><code class="sourceCode r"><span class="hl-variable">cran_db</span> <span class="hl-operator">%&gt;%</span>
  <span class="hl-function">filter</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">Language</span> <span class="hl-operator">==</span> <span class="hl-string">"fr"</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">%&gt;%</span>
  <span class="hl-namespace">pander</span><span class="hl-operator">::</span><span class="hl-function">pandoc.table</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">split.tables</span> <span class="hl-operator">=</span> <span class="hl-constant-builtin">Inf</span><span class="hl-punctuation-bracket">)</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<table>
<colgroup>
<col width="13%">
<col width="31%">
<col width="32%">
<col width="10%">
<col width="10%">
</colgroup>
<thead>
<tr class="header">
<th align="center">Package</th>
<th align="center">Title</th>
<th align="center">Description</th>
<th align="center">Encoding</th>
<th align="center">Language</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">SARP.moodle</td>
<td align="center">XML Output Functions for Easy
Creation of Moodle Questions</td>
<td align="center">Provides a set of basic
functions for creating Moodle
XML output files suited for
importing questions in Moodle
(a learning management
system, see
<a class="uri" href="https://moodle.org/">https://moodle.org/</a> for more
information).</td>
<td align="center">UTF-8</td>
<td align="center">fr</td>
</tr>
</tbody>
</table>
<p>We see that neither of these packages have their title or description field in
french. Moreover, one package has UTF8 encoding and the other Latin1.</p>
<p>So this Language field is not very useful. I am not sure if this field is useful
for any other purpose than information</p>
</section>
<section class="section level1" id="trying-to-detect-languages-of-packages">
<h1>Trying to detect languages of Packages</h1>
<p>How can we have some insight on CRAN package language ?</p>
<p>We can analyse the cran database using the Google’s Compact Language Detector. ROpensci has made 2 wrappers for using it in version 2 (<a href="https://github.com/ropensci/cld2"><code>cld2</code></a>) and version 3 (<a href="https://github.com/ropensci/cld3"><code>cld3</code></a>).</p>
<p>We will be using the version 2, as <code>cld3</code> is still experimental.</p>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode r"><code class="sourceCode r"><span class="hl-variable">cran_db_with_lang</span> <span class="hl-operator">&lt;-</span> <span class="hl-variable">cran_db</span> <span class="hl-operator">%&gt;%</span>
  <span class="hl-function">mutate</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">detected</span> <span class="hl-operator">=</span> <span class="hl-namespace">cld2</span><span class="hl-operator">::</span><span class="hl-function">detect_language</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">Description</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-variable-parameter">lang_code</span> <span class="hl-operator">=</span> <span class="hl-boolean">FALSE</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<div class="code-copy-outer-scaffold">
<div class="sourceCode code-with-copy"><pre class="sourceCode r"><code class="sourceCode r"><span class="hl-variable">nb_of_lg_en</span> <span class="hl-operator">&lt;-</span> <span class="hl-variable">cran_db_with_lang</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">filter</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">detected</span> <span class="hl-operator">==</span> <span class="hl-string">"ENGLISH"</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">count</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">detected</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">pull</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">n</span><span class="hl-punctuation-bracket">)</span>
<span class="hl-function">ggplot</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">cran_db_with_lang</span> <span class="hl-operator">%&gt;%</span> <span class="hl-function">filter</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable">detected</span> <span class="hl-operator">!=</span> <span class="hl-string">"ENGLISH"</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">geom_bar</span><span class="hl-punctuation-bracket">(</span><span class="hl-function">aes</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">x</span> <span class="hl-operator">=</span> <span class="hl-variable">detected</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-variable-parameter">fill</span> <span class="hl-operator">=</span> <span class="hl-string">"skyblue"</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">labs</span><span class="hl-punctuation-bracket">(</span><span class="hl-variable-parameter">title</span> <span class="hl-operator">=</span> <span class="hl-string">"Language of packages"</span><span class="hl-punctuation-delimiter">,</span> <span class="hl-variable-parameter">subtitle</span> <span class="hl-operator">=</span> <span class="hl-namespace">glue</span><span class="hl-operator">::</span><span class="hl-function">glue</span><span class="hl-punctuation-bracket">(</span><span class="hl-string">"{nb_of_lg_en} packages detected as English"</span><span class="hl-punctuation-bracket">)</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">coord_flip</span><span class="hl-punctuation-bracket">(</span><span class="hl-punctuation-bracket">)</span> <span class="hl-operator">+</span>
  <span class="hl-function">theme_light</span><span class="hl-punctuation-bracket">(</span><span class="hl-punctuation-bracket">)</span></code></pre></div>
<button aria-label="Copy code" class="code-copy-button" title="Copy to Clipboard"><i class="bi"></i></button>
</div>
<p><img alt="Bar chart: Language of packages" class="img-fluid" src="https://cderv.dev/posts/2018-03-11-non-english-pkg-in-cran/unnamed-chunk-7-1.png" width="672"></p>
<p>There are very few packages that seems to have non english description field.</p>
<table>
<colgroup>
<col width="10%">
<col width="15%">
<col width="58%">
<col width="5%">
<col width="5%">
<col width="5%">
</colgroup>
<thead>
<tr class="header">
<th align="center">Package</th>
<th align="center">Title</th>
<th align="center">Description</th>
<th align="center">Encoding</th>
<th align="center">Language</th>
<th align="center">detected</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">casen</td>
<td align="center">Metodos De Estimacion Con
Disenio Probabilistico y
Estratificado en Encuesta
CASEN (Estimation Methods with
Probabilistic Stratified
Sampling in CASEN Survey)</td>
<td align="center">Funciones para realizar
estadistica descriptiva e
inferencia con el disenio
complejo de la Encuesta CASEN
(Encuesta de Caracterizacion
Socio-Economica). Incluye
datasets que permiten
armonizar los codigos de
comunas que cambian entre
anios y permite convertir a
los codigos oficiales de
SUBDERE. (Functions to
compute descriptive and
inferential statistics with
CASEN Survey [Socio-Economic
Characterization Survey]
complex design. Includes
datasets to harmonize commune
codes that change across years
and allows to convert to
official SUBDERE codes.)</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">SPANISH</td>
</tr>
<tr class="even">
<td align="center">censo2017</td>
<td align="center">Base de Datos de Facil Acceso
del Censo 2017 de Chile (2017
Chilean Census Easy Access
Database)</td>
<td align="center">Provee un acceso conveniente a
mas de 17 millones de
registros de la base de
datos del Censo 2017. Los
datos fueron importados desde
el DVD oficial del INE
usando el Convertidor REDATAM
creado por Pablo De
Grande. Esta paquete esta
documentado intencionalmente
en castellano asciificado
para que funcione sin problema
en diferentes plataformas.
(Provides convenient access to
more than 17 million records
from the Chilean Census
2017 database. The datasets
were imported from the
official DVD provided by
the Chilean National Bureau of
Statistics by using the
REDATAM converter created by
Pablo De Grande and in
addition it includes the
maps accompanying these
datasets.)</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">SPANISH</td>
</tr>
<tr class="odd">
<td align="center">chilemapas</td>
<td align="center">Mapas de las Divisiones
Politicas y Administrativas de
Chile (Maps of the Political
and Administrative Divisions
of Chile)</td>
<td align="center">Mapas terrestres con
topologias simplificadas.
Estos mapas no tienen
precision geodesica, por lo
que aplica el DFL-83 de 1979
de la Republica de Chile y
se consideran referenciales
sin validez legal. No se
incluyen los territorios
antarticos y bajo ningun
evento estos mapas
significan que exista una
cesion u ocupacion de
territorios soberanos en
contra del Derecho
Internacional por parte de
Chile. Esta paquete esta
documentado intencionalmente
en castellano asciificado para
que funcione sin problema
en diferentes plataformas.
(Terrestrial maps with
simplified toplogies. These
maps lack geodesic
precision, therefore DFL-83
1979 of the Republic of Chile
applies and are considered
to have no legal validity.
Antartic territories are
excluded and under no event
these maps mean there is a
cession or occupation of
sovereign territories against
International Laws from
Chile. This package was
intentionally documented in
asciified spanish to make it
work without problem on
different platforms.)</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">SPANISH</td>
</tr>
<tr class="even">
<td align="center">confreq</td>
<td align="center">Configural Frequencies
Analysis Using Log-Linear
Modeling</td>
<td align="center">Offers several functions for
Configural Frequencies
Analysis (CFA), which is a
useful statistical tool for
the analysis of multiway
contingency tables. CFA was
introduced by G. A. Lienert as
‘Konfigurations Frequenz
Analyse - KFA’. Lienert, G. A.
(1971). Die
Konfigurationsfrequenzanalyse:
I. Ein neuer Weg zu Typen und
Syndromen. Zeitschrift
für Klinische Psychologie und
Psychotherapie, 19(2), 99–115.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">GERMAN</td>
</tr>
<tr class="odd">
<td align="center">covid19italy</td>
<td align="center">The 2019 Novel Coronavirus
COVID-19 (2019-nCoV) Italy
Dataset</td>
<td align="center">Provides a daily summary of
the Coronavirus (COVID-19)
cases in Italy by country,
region and province level.
Data source: Presidenza del
Consiglio dei Ministri -
Dipartimento della Protezione
Civile
<a class="uri" href="http://www.protezionecivile.it/">http://www.protezionecivile.it/</a>.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">ITALIAN</td>
</tr>
<tr class="even">
<td align="center">datos</td>
<td align="center">Traduce al Español Varios
Conjuntos de Datos de Práctica</td>
<td align="center">Provee una versión traducida
de los siguientes
conjuntos de datos:
‘airlines’, ‘airports’,
‘AwardsManagers’,
‘babynames’, ‘Batting’,
‘diamonds’, ‘faithful’,
‘fueleconomy’, ‘Fielding’,
‘flights’, ‘gapminder’,
‘gss_cat’, ‘iris’, ‘Managers’,
‘mpg’, ‘mtcars’, ‘atmos’,
‘People, ’Pitching’, ‘planes’,
‘presidential’, ‘table1’,
‘table2’, ‘table3’, ‘table4a’,
‘table4b’, ‘table5’,
‘vehicles’, ‘weather’, ‘who’.
English: It provides a
Spanish translated version of
the datasets listed above.</td>
<td align="center">UTF-8</td>
<td align="center">es</td>
<td align="center">SPANISH</td>
</tr>
<tr class="odd">
<td align="center">ExpDes.pt</td>
<td align="center">Pacote Experimental Designs
(Portugues)</td>
<td align="center">Pacote para análise de
delineamentos experimentais
(DIC, DBC e DQL), experimentos
em esquema fatorial duplo (em
DIC e DBC), experimentos em
parcelas subdivididas (em DIC
e DBC), experimentos em
esquema fatorial duplo com um
tratamento adicional (em DIC e
DBC), experimentos em fatorial
triplo (em DIC e DBC) e
experimentos em esquema
fatorial triplo com um
tratamento adicional (em DIC e
DBC), fazendo analise de
variancia e comparacao de
multiplas medias (para
tratamentos qualitativos), ou
ajustando modelos de regressao
ate a terceira potencia (para
tratamentos quantitativos);
analise de residuos (Ferreira,
Cavalcanti and Nogueira, 2014)
<a class="uri" href="doi:10.4236/am.2014.519280">doi:10.4236/am.2014.519280</a>.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">PORTUGUESE</td>
</tr>
<tr class="even">
<td align="center">geouy</td>
<td align="center">Geographic Information of
Uruguay</td>
<td align="center">The toolbox have functions to
load and process geographic
information for Uruguay.
And extra-function to get
address coordinates and
orthophotos through the
uruguayan ‘IDE’ API
<a class="uri" href="https://www.gub.uy/infraestructura-datos-espaciales/tramites-y-servicios/servicios/servicio-direcciones-geograficas">https://www.gub.uy/infraestructura-datos-espaciales/tramites-y-servicios/servicios/servicio-direcciones-geograficas</a>.</td>
<td align="center">UTF-8</td>
<td align="center">en, es</td>
<td align="center">SPANISH</td>
</tr>
<tr class="odd">
<td align="center">guaguas</td>
<td align="center">Nombres Inscritos en Chile
(1920 - 2019)</td>
<td align="center">Datos de nombres inscritos en
Chile entre 1920 y 2019,
de acuerdo al Servicio de
Registro Civil. Este
paquete incluye todos los
nombres con al menos 15
ocurrencias anuales.
English: Chilean baby names
registered in the Civil
Registry Service. This
package contains all names
used at least 15 times
per year, from 1920 to 2019.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">SPANISH</td>
</tr>
<tr class="even">
<td align="center">HBV.IANIGLA</td>
<td align="center">Modular Hydrological Model</td>
<td align="center">The HBV hydrological model
(Bergström, S. and Lindström,
G., (2015)
<a class="uri" href="doi:10.1002/hyp.10510">doi:10.1002/hyp.10510</a>) has
been split in modules to allow
the user to build his/her own
model. This version was
developed by the author in
IANIGLA-CONICET (Instituto
Argentino de Nivologia,
Glaciologia y Ciencias
Ambientales - Consejo Nacional
de Investigaciones Cientificas
y Tecnicas) for hydroclimatic
studies in the Andes.
HBV.IANIGLA incorporates
routines for clean and debris
covered glacier melt
simulations.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">SPANISH</td>
</tr>
<tr class="odd">
<td align="center">ibb</td>
<td align="center">R Wrapper for Istanbul
Municipality Open Data Portal</td>
<td align="center">Call wrappers for Istanbul
Metropolitan
Municipality’s Open Data
Portal (Turkish: Istanbul
Büyüksehir Belediyesi Açik
Veri Portali) at
<a class="uri" href="https://data.ibb.gov.tr/en/">https://data.ibb.gov.tr/en/</a>.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">TURKISH</td>
</tr>
<tr class="even">
<td align="center">KenSyn</td>
<td align="center">Knowledge Synthesis in
Agriculture - From
Experimental Network to
Meta-Analysis</td>
<td align="center">Demo and dataset accompaying
the books : De l’analyse des
réseaux expérimentaux à la
méta-analyse: Méthodes et
applications avec le logiciel
R pour les sciences
agronomiques et
environnementales (Published
2018-06-28, Quae, for french
version) by David Makowski,
Francois Piraux and Francois
Brun -
<a class="uri" href="https://www.quae.com/produit/1514/9782759228164/de-l-analyse-des-reseaux-experimentaux-a-la-meta-analyse">https://www.quae.com/produit/1514/9782759228164/de-l-analyse-des-reseaux-experimentaux-a-la-meta-analyse</a>
Knowledge Synthesis in
Agriculture : from
Experimental Network to
Meta-Analysis (in preparation
for 2018-06, Springer , for
English version) by David
Makowski, Francois Piraux and
Francois Brun A full
description of all the
material is in both books.
ACKNOWLEDGMENTS : The French
network “RMT modeling and data
analysis for agriculture”
(<a class="uri" href="http://www.modelia.org">http://www.modelia.org</a>)
have contributed to the
development of this R package.
This project and network are
lead by ACTA (French Technical
Institute for Agriculture) and
was funded by a grant from the
Ministry of Agriculture and
Fishing of France.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">FRENCH</td>
</tr>
<tr class="odd">
<td align="center">LabRS</td>
<td align="center">Laboratorio di “Ricerca
Sociale con R”</td>
<td align="center">Dati, scripts e funzioni per
il libro “Ricerca sociale con
R. Concetti e funzioni base
per la ricerca sociale”
(Datasets, scripts and
functions to support the book
“Ricerca sociale con R.
Concetti e funzioni base per
la ricerca sociale”).</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">ITALIAN</td>
</tr>
<tr class="even">
<td align="center">labstatR</td>
<td align="center">Libreria Del Laboratorio Di
Statistica Con R</td>
<td align="center">Insieme di funzioni di
supporto al volume
“Laboratorio di
Statistica con R”,
Iacus-Masarotto, MacGraw-Hill
Italia, 2006. This
package contains sets of
functions defined in
“Laboratorio di
Statistica con R”,
Iacus-Masarotto, MacGraw-Hill
Italia, 2006. Function
names and docs are in italian
as well.</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">ITALIAN</td>
</tr>
<tr class="odd">
<td align="center">LSAmitR</td>
<td align="center">Daten, Beispiele und
Funktionen zu ‘Large-Scale
Assessment mit R’</td>
<td align="center">Dieses R-Paket stellt
Zusatzmaterial in Form von
Daten, Funktionen
und R-Hilfe-Seiten für den
Herausgeberband Breit, S. und
Schreiner, C.
(Hrsg.). (2016). “Large-Scale
Assessment mit R: Methodische
Grundlagen der
österreichischen
Bildungsstandardüberprüfung.”
Wien: facultas.
(ISBN: 978-3-7089-1343-8,
<a class="uri" href="https://www.bifie.at/node/3770">https://www.bifie.at/node/3770</a>)
zur Verfügung.</td>
<td align="center">UTF-8</td>
<td align="center">de</td>
<td align="center">GERMAN</td>
</tr>
<tr class="even">
<td align="center">MSMwRA</td>
<td align="center">Multivariate Statistical
Methods with R Applications</td>
<td align="center">Data sets in the book entitled
“Multivariate Statistical
Methods with R Applications”,
H.Bulut (2018).
The book will be published in
Turkish and the original name
of this book will be “R
Uygulamalari ile Cok
Degiskenli Istatistiksel
Yontemler”.</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">TURKISH</td>
</tr>
<tr class="odd">
<td align="center">MultivariateAnalysis</td>
<td align="center">Pacote Para Analise
Multivariada</td>
<td align="center">Package with multivariate
analysis methodologies for
experiment evaluation. The
package estimates
dissimilarity measures, builds
dendrograms, obtains MANOVA,
principal components,
canonical variables, etc.
(Pacote com metodologias de
analise multivariada para
avaliação de experimentos. O
pacote estima medidas de
dissimilaridade, construi de
dendogramas, obtem a MANOVA,
componentes principais,
variáveis canônicas, etc.)</td>
<td align="center">UTF-8</td>
<td align="center">pt-BR</td>
<td align="center">PORTUGUESE</td>
</tr>
<tr class="even">
<td align="center">MVar.pt</td>
<td align="center">Analise multivariada
(brazilian portuguese)</td>
<td align="center">Pacote para analise
multivariada, tendo funcoes
que executam analise de
correspondencia simples (CA) e
multipla (MCA), analise de
componentes principais (PCA),
analise de correlacao canonica
(CCA), analise fatorial (FA),
escalonamento multidimensional
(MDS), analise discriminante
linear (LDA) e quadratica
(QDA), analise de cluster
hierarquico e nao hierarquico,
regressao linear simples e
multipla, analise de multiplos
fatores (MFA) para dados
quantitativos, qualitativos,
de frequencia (MFACT) e dados
mistos, biplot, scatter plot,
projection pursuit (PP), grant
tour e outras funcoes uteis
para a analise multivariada.</td>
<td align="center">NA</td>
<td align="center">pt_BR</td>
<td align="center">PORTUGUESE</td>
</tr>
<tr class="odd">
<td align="center">orloca.es</td>
<td align="center">Spanish version of orloca
package. Modelos de
localizacion en investigacion
operativa</td>
<td align="center">Help and demo in Spanish of
the orloca package. (Ayuda y
demo en espanol del paquete
orloca.) Objetos y metodos
para manejar y resolver el
problema de localizacion de
suma minima, tambien conocido
como problema de Fermat-Weber.
El problema de localizacion de
suma minima busca un punto tal
que la suma ponderada de las
distancias a los puntos de
demanda se minimice. Vease
“The Fermat-Weber location
problem revisited” por
Brimberg, Mathematical
Programming, 1, pag. 71-76,
1995. &lt;DOI:
10.1007/BF01592245&gt;. Se
usan algoritmos generales de
optimizacion global para
resolver el problema, junto
con el metodo adhoc Weiszfeld,
vease “Sur le point pour
lequel la Somme des distance
de n points donnes est
minimum”, por Weiszfeld,
Tohoku Mathematical Journal,
First Series, 43, pag.
355-386, 1937 o “On the point
for which the sum of the
distances to n given points is
minimum”, por E. Weiszfeld y
F. Plastria, Annals of
Operations Research, 167, pg.
7-41, 2009.
<a class="uri" href="DOI:10.1007/s10479-008-0352-z">DOI:10.1007/s10479-008-0352-z</a>.</td>
<td align="center">NA</td>
<td align="center">es</td>
<td align="center">SPANISH</td>
</tr>
<tr class="even">
<td align="center">PortalHacienda</td>
<td align="center">Acceder Con R a Los Datos Del
Portal De Hacienda</td>
<td align="center">Obtener listado de datos,
acceder y extender series del
Portal de Datos de
Hacienda.Las proyecciones se
realizan con ‘forecast’,
Hyndman RJ, Khandakar Y (2008)
<a class="uri" href="doi:10.18637/jss.v027.i03">doi:10.18637/jss.v027.i03</a>.
Search, download and
forecast time-series from the
Ministry of Economy of
Argentina. Forecasts are built
with the ‘forecast’ package,
Hyndman RJ, Khandakar Y
(2008)
<a class="uri" href="doi:10.18637/jss.v027.i03">doi:10.18637/jss.v027.i03</a>.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">SPANISH</td>
</tr>
<tr class="odd">
<td align="center">praktikum</td>
<td align="center">Kvantitatiivsete meetodite
praktikumi asjad / Functions
used in the course
“Quantitative methods in
behavioural sciences”
(SHPH.00.004), University of
Tartu</td>
<td align="center">Kasulikud funktsioonid
kvantitatiivsete mudelite
kursuse (SHPH.00.004)
jaoks</td>
<td align="center">NA</td>
<td align="center">et</td>
<td align="center">ESTONIAN</td>
</tr>
<tr class="even">
<td align="center">proustr</td>
<td align="center">Tools for Natural Language
Processing in French</td>
<td align="center">Tools for Natural Language
Processing in French and texts
from Marcel Proust’s
collection “A La Recherche
Du Temps Perdu”. The novels
contained in this collection
are “Du cote de chez Swann”, “A l’ombre des jeunes
filles en fleurs”,“Le Cote de
Guermantes”, “Sodome et
Gomorrhe I et II”, “La
Prisonniere”, “Albertine
disparue”, and “Le Temps
retrouve”.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">FRENCH</td>
</tr>
<tr class="odd">
<td align="center">qha</td>
<td align="center">Qualitative Harmonic Analysis</td>
<td align="center">Multivariate description of
the state changes of a
qualitative variable by
Correspondence
Analysis and Clustering. See:
Deville, J.C., &amp;
Saporta, G. (1983).
Correspondence
analysis, with an extension
towards nominal time series.
Journal of
econometrics, 22(1-2),
169-189.
Corrales, M.L., &amp; Pardo, C.E.
(2015)
<a class="uri" href="doi:10.15332/s2027-3355.2015.0001.01">doi:10.15332/s2027-3355.2015.0001.01</a>.
Analisis de
datos longitudinales
cualitativos con analisis de
correspondencias y
clasificacion.
Comunicaciones en
Estadistica, 8(1), 11-32.</td>
<td align="center">latin1</td>
<td align="center">NA</td>
<td align="center">SPANISH</td>
</tr>
<tr class="even">
<td align="center">qqr</td>
<td align="center">Data from Brazilian Soccer
Championship</td>
<td align="center">Get data about the Brazilian
soccer championship since
2014. Official data can be
found at
<a class="uri" href="https://www.cbf.com.br/futebol-brasileiro/competicoes/campeonato-brasileiro-serie-a/">https://www.cbf.com.br/futebol-brasileiro/competicoes/campeonato-brasileiro-serie-a/</a>.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">PORTUGUESE</td>
</tr>
<tr class="odd">
<td align="center">Rarefy</td>
<td align="center">Rarefaction Methods</td>
<td align="center">Includes functions for the
calculation of spatially and
non-spatially explicit
rarefaction curves using
different indices of
taxonomic, functional and
phylogenetic diversity. The
user can also rarefy any
biodiversity metric as
provided by a self-written
function (or an already
existent one) that gives as
output a vector with the
values of a certain index of
biodiversity calculated per
plot (Ricotta, C., Acosta, A.,
Bacaro, G., Carboni, M.,
Chiarucci, A., Rocchini, D.,
Pavoine, S. (2019)
<a class="uri" href="doi:10.1016/j.ecolind.2019.105606">doi:10.1016/j.ecolind.2019.105606</a>;
Bacaro, G., Altobelli, A.,
Cameletti, M., Ciccarelli, D.,
Martellos, S., Palmer, M. W.,
… Chiarucci, A. (2016)
<a class="uri" href="doi:10.1016/j.ecolind.2016.04.026">doi:10.1016/j.ecolind.2016.04.026</a>;
Bacaro, G., Rocchini, D.,
Ghisla, A., Marcantonio, M.,
Neteler, M., &amp; Chiarucci, A.
(2012)
<a class="uri" href="doi:10.1016/j.ecocom.2012.05.007">doi:10.1016/j.ecocom.2012.05.007</a>).</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">ITALIAN</td>
</tr>
<tr class="even">
<td align="center">rasterdiv</td>
<td align="center">Diversity Indices for
Numerical Matrices</td>
<td align="center">Providing functions to
calculate indices of diversity
on numerical matrices based on
information theory. The
rationale behind the package
is described in Rocchini,
Marcantonio and Ricotta (2017)
<a class="uri" href="doi:10.1016/j.ecolind.2016.07.039">doi:10.1016/j.ecolind.2016.07.039</a>
and Rocchini, Marcantonio,…,
Ricotta (2021)
<a class="uri" href="doi:10.1101/2021.01.23.427872">doi:10.1101/2021.01.23.427872</a>.</td>
<td align="center">UTF-8</td>
<td align="center">en-GB</td>
<td align="center">ITALIAN</td>
</tr>
<tr class="odd">
<td align="center">RcmdrPlugin.EACSPIR</td>
<td align="center">Plugin de R-Commander para el
Manual ‘EACSPIR’</td>
<td align="center">Este paquete proporciona una
interfaz grafica de usuario
(GUI) para algunos de los
procedimientos estadisticos
detallados en un curso de
‘Estadistica aplicada a las
Ciencias Sociales mediante el
programa informatico R’
(EACSPIR). LA GUI se ha
desarrollado como un Plugin
del programa R-Commander.</td>
<td align="center">NA</td>
<td align="center">es</td>
<td align="center">SPANISH</td>
</tr>
<tr class="even">
<td align="center">Sofi</td>
<td align="center">Interfaz interactiva con fines
didacticos</td>
<td align="center">Este paquete tiene la
finalidad de ayudar a aprender
de una forma interactiva,
teniendo ejemplos y la
posibilidad de resolver nuevos
al mismo tiempo. Apuntes de
clase interactivos.</td>
<td align="center">UTF-8</td>
<td align="center">es</td>
<td align="center">SPANISH</td>
</tr>
<tr class="odd">
<td align="center">SpatialRegimes</td>
<td align="center">Spatial Constrained
Clusterwise Regression</td>
<td align="center">A collection of functions for
estimating spatial regimes,
aggregations of neighboring
spatial units that are
homogeneous in functional
terms. The term spatial
regime, therefore, should not
be understood as a synonym for
cluster. More precisely, the
term cluster does not
presuppose any functional
relationship between the
variables considered, while
the term regime is linked to a
regressive relationship
underlying the spatial
process. For more information,
please see Postiglione, P.,
Andreano, M.S., Benedetti R.
(2013)
<a class="uri" href="doi:10.1007/s10614-012-9325-z">doi:10.1007/s10614-012-9325-z</a>
, Andreano, M.S., Benedetti,
R., and Postiglione, P. (2017)
<a class="uri" href="doi:10.1007/s11135-016-0415-1">doi:10.1007/s11135-016-0415-1</a>
, Bille’, A.G., Benedetti, R.,
and Postiglione, P. (2017)
<a class="uri" href="doi:10.1080/17421772.2017.1286373">doi:10.1080/17421772.2017.1286373</a>.</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">ITALIAN</td>
</tr>
<tr class="even">
<td align="center">swissdd</td>
<td align="center">Get Swiss Federal and Cantonal
Vote Results from
Opendata.swiss</td>
<td align="center">Builds upon the real time data
service as well as the archive
for national votes
<a class="uri" href="https://opendata.swiss/api/3/action/package_show?id=echtzeitdaten-am-abstimmungstag-zu-eidgenoessischen-abstimmungsvorlagen">https://opendata.swiss/api/3/action/package_show?id=echtzeitdaten-am-abstimmungstag-zu-eidgenoessischen-abstimmungsvorlagen</a>
and cantonal votes
<a class="uri" href="https://opendata.swiss/api/3/action/package_show?id=echtzeitdaten-am-abstimmungstag-zu-kantonalen-abstimmungsvorlagen">https://opendata.swiss/api/3/action/package_show?id=echtzeitdaten-am-abstimmungstag-zu-kantonalen-abstimmungsvorlagen</a>.
It brings the results of Swiss
popular votes, aggregated at
the geographical level of
choice, into R. Additionally,
it allows to retrieve data
from the Swissvotes-Database,
one of the most comprehensive
data platforms on Swiss
referendums and initiatives
<a class="uri" href="https://swissvotes.ch/page/dataset/swissvotes_dataset.csv">https://swissvotes.ch/page/dataset/swissvotes_dataset.csv</a>.</td>
<td align="center">UTF-8</td>
<td align="center">NA</td>
<td align="center">GERMAN</td>
</tr>
<tr class="odd">
<td align="center">Tratamentos.ad</td>
<td align="center">“Pacote Para Analise De
Experimentos Com Testemunhas
Adicionais””</td>
<td align="center">Pacote para a analise de
experimentos com um ou dois
fatores com
testemunhas adicionais
conduzidos no delineamento
inteiramente
casualizado ou em blocos
casualizados.
“Package for the analysis of
one or two-factor experiments
with additional
controls conducted in a
completely randomized design
or in a randomized
block design”.</td>
<td align="center">UTF-8</td>
<td align="center">pt-BR</td>
<td align="center">PORTUGUESE</td>
</tr>
</tbody>
</table>
<p>The detection by <code>cld2</code> does not seem to be 100% correct.</p>
<p>However, it helps us isolate some non english packages and it highlights that
English is the language to go to avoid encoding issues and specific
configurations in package.
I will now continue to look into those packages I just found to see if they have
the same encoding issue as French package… and it seems so !</p>
</section>

]]></description>
<category>R</category>
<guid>https://cderv.dev/posts/2018-03-11-non-english-pkg-in-cran/index.html</guid>
<pubDate>Sun, 11 Mar 2018 00:00:00 +0000</pubDate>
<media:content url="https://cderv.dev/posts/2018-03-11-non-english-pkg-in-cran/unnamed-chunk-3-1.png" medium="image" type="image/png" width="144" height="103"/>
</item>
<item>
<title>About download methods &amp; OS</title>
<link>https://cderv.dev/posts/2016-12-26-download-method/index.html</link>
<description><![CDATA[




<p>End 2016, Working on a <a href="https://github.com/r-pkgs/remotes/pull/46">PR</a> for package <code>remotes</code> package, I looked into how <code>download.file</code> methods evolved with R version, trying to understand how it works depending on the OS or the url type.</p>
<p>This post is my understanding at the time. It is an import of a <a href="">gist</a> I made in December 2016 with a small revamp. I did not have a blog at that time, so it was more some notes but I think it worth sharing.</p>
<section class="section level1" id="a-deep-look-into-download.file-methods-history">
<h1>A deep look into <code>download.file</code> methods history</h1>
<p>First, I did some digging in R News file to understand what changed with this base R function. Then, I underlined what should be considered since R 3.3.2 in order to make right choice for my PR.</p>
<section class="section level2" id="history-of-download.file-function-in-base-r">
<h2 class="anchored" data-anchor-id="history-of-download.file-function-in-base-r">History of <code>download.file</code> function in base R</h2>
<p><em>from <a href="https://cran.r-project.org/doc/manuals/r-release/NEWS.html">R news</a></em></p>
<section class="section level3" id="r-3.3.0">
<h3 class="anchored" data-anchor-id="r-3.3.0">R 3.3.0</h3>
<section class="section level4" id="what-is-important">
<h4 class="anchored" data-anchor-id="what-is-important">What is important</h4>
<ul>
<li>All builds have support for https</li>
<li>On windows, <em>“wininet”</em> still is the default (since 3.2.2)</li>
<li>On windows, method <em>“auto”</em> uses <em>“libcurl”</em> only for ftps.</li>
<li>On windows, <code>setInternet2()</code> is depreciated (no effect) and will be removed</li>
</ul>
</section>
<section class="section level4" id="extracted-from-r-news">
<h4 class="anchored" data-anchor-id="extracted-from-r-news">Extracted from R news</h4>
<blockquote>
<p>All builds have support for https: URLs in the default methods for <code>download.file()</code>, <code>url()</code> and code making use of them. Unfortunately that cannot guarantee that any particular https: URL can be accessed. For example, server and client have to successfully negotiate a cryptographic protocol (TLS/SSL, …) and the server’s identity has to be verifiable via the available certificates. Different access methods may allow different protocols or use private certificate bundles: we encountered a https: CRAN mirror which could be accessed by one browser but not by another nor by download.file() on the same Linux machine.</p>
</blockquote>
<!-- -->
<blockquote>
<p>(Windows only) download.file() with default method = “auto” and a ftps:// URL chooses “libcurl” if that is available.</p>
</blockquote>
<!-- -->
<blockquote>
<p>(Windows only) Function setInternet2() has no effect and will be removed in due course. The choice between methods “internal” and “wininet” is now made by the method arguments of url() and download.file() and their defaults can be set via options. The out-of-the-box default remains “wininet” (as it has been since R 3.2.2)</p>
</blockquote>
</section>
</section>
<section class="section level3" id="r-3.2.5">
<h3 class="anchored" data-anchor-id="r-3.2.5">R 3.2.5</h3>
<section class="section level4" id="what-is-important-1">
<h4 class="anchored" data-anchor-id="what-is-important-1">What is important</h4>
<ul>
<li>On windows, <em>“wininet”</em> is now the default. <strong>It changes how proxy need to be set.</strong></li>
<li>On windows, <em>“internal”</em> uses <em>“wininet”</em> by defaut (<code>setInternet2(TRUE)</code>) - <code>download.file()</code> can read https then.</li>
<li>On non windows, <em>“libcurl”</em> is use by default if available and if url is https or ftps</li>
</ul>
</section>
<section class="section level4" id="extracted-form-r-news">
<h4 class="anchored" data-anchor-id="extracted-form-r-news">Extracted form R News</h4>
<blockquote>
<p>It is now easier to use secure downloads from https:// URLs on builds which support them: no longer do non-default options need to be selected to do so. In particular, packages can be installed from repositories which offer https:// URLs, and those listed by setRepositories() now do so (for some of their mirrors). Support for https:// URLs is available on Windows, and on other platforms if support for libcurl was compiled in and if that supports the https protocol (system installations can be expected to do). So https:// support can be expected except on rather old OSes (an example being OS X ‘Snow Leopard’, where a non-system version of libcurl can be used).</p>
</blockquote>
<!-- -->
<blockquote>
<p>(Windows only) The default method for accessing URLs via download.file() and url() has been changed to be “wininet” using Windows API calls. This changes the way proxies need to be set and security settings made: there have been some reports of ftp: sites being inaccessible under the new default method (but the previous methods remain available).</p>
</blockquote>
<blockquote>
<p>(Non-Windows only) download.file() with default method = “auto” now chooses “libcurl” if that is available and a https:// or ftps:// URL is used</p>
</blockquote>
<!-- -->
<blockquote>
<p>(Windows only) setInternet2(TRUE) is now the default. The command-line option –internet2 and environment variable R_WIN_INTERNET2 are now ignored. Thus by default the “internal” method for download.file() and url() uses the “wininet” method: to revert to the previous default use setInternet2(FALSE). This means that https:// URLs can be read by default by download.file() (they have been readable by file() and url() since R 3.2.0). There are implications for how proxies need to be set (see ?download.file)</p>
</blockquote>
</section>
</section>
<section class="section level3" id="r-3.2.0">
<h3 class="anchored" data-anchor-id="r-3.2.0">R 3.2.0</h3>
<section class="section level4" id="what-is-important-2">
<h4 class="anchored" data-anchor-id="what-is-important-2">What is important</h4>
<ul>
<li>Apparition of <em>“libcurl”</em> method</li>
<li>Apparition of <em>“wininet”</em> method</li>
<li><code>download.file(method = "lynx")</code> is defunct.</li>
</ul>
</section>
<section class="section level4" id="extract-from-r-news">
<h4 class="anchored" data-anchor-id="extract-from-r-news">Extract from R News</h4>
<ul>
<li>Optional use of libcurl (version 7.28.0 from Oct 2012 or later) for Internet access:
<ul>
<li>capabilities(“libcurl”) reports if this is available.</li>
<li>libcurlVersion() reports the version in use, and other details of the “libcurl” build including which URL schemes it supports.</li>
<li>curlGetHeaders() retrieves the headers for http://, https://, ftp:// and ftps:// URLs: analysis of these headers can provide insights into the ‘existence’ of a URL (it might for example be permanently redirected) and is so used in R CMD check –as-cran.</li>
<li>download.file() has a new optional method “libcurl” which will handle more URL schemes, follow redirections, and allows simultaneous downloads of multiple URLs.</li>
<li>url() has a new method “libcurl” which handles more URL schemes and follows redirections. The default method is controlled by a new option url.method, which applies also to the opening of URLs via file() (which happens implicitly in functions such as read.table.)</li>
<li>When file() or url() is invoked with a https:// or ftps:// URL which the current method cannot handle, it switches to a suitable method if one is available.</li>
</ul>
</li>
<li>(Windows.) The DLLs ‘internet.dll’ and ‘internet2.dll’ have been merged. In this version it is safe to switch (repeatedly) between the internal and Windows internet functions within an R session. The Windows internet functions are still selected by flag –internet2 or setInternet2(). This can be overridden for an url() connection via its new method argument.
<ul>
<li>download.file() has new method “wininet”, selected as the default by –internet2 or setInternet2().</li>
</ul>
</li>
</ul>
</section>
</section>
<section class="section level3" id="r-3.1.0">
<h3 class="anchored" data-anchor-id="r-3.1.0">R 3.1.0</h3>
<ul>
<li><code>download.file(method = "lynx")</code> is deprecated.</li>
</ul>
</section>
<section class="section level3" id="and-before-r-3.1.0">
<h3 class="anchored" data-anchor-id="and-before-r-3.1.0">and before R 3.1.0</h3>
<p>Sorry, I did not looked so far into previous version.</p>
</section>
</section>
<section class="section level2" id="so-what-is-going-on-in-the-r-3.3.2">
<h2 class="anchored" data-anchor-id="so-what-is-going-on-in-the-r-3.3.2">So, what is going on in the R 3.3.2 ?</h2>
<p>In this part, I sum up what I understand about methods for <code>download.file()</code></p>
<section class="section level3" id="default-methods">
<h3 class="anchored" data-anchor-id="default-methods">Default methods</h3>
<ul>
<li>On non windows
<ul>
<li><em>“libcurl”</em> is used by default for https and for ftps</li>
<li><em>“internal”</em> is used by default for others url types</li>
<li><em>“wget”</em> and <em>“curl”</em> can be selected but respective program must be installed</li>
</ul>
</li>
<li>On windows
<ul>
<li><em>“wininet”</em> is used by default for all url types apart from ftps</li>
<li><em>“libcurl”</em> is used by default for ftps url.<br>However libcurl is optional on windows. Must be checked with <code>capabilities("libcurl")</code></li>
<li><em>“wget”</em> and <em>“curl”</em> can be selected but respective program must be installed</li>
</ul>
</li>
</ul>
</section>
<section class="section level3" id="https-support">
<h3 class="anchored" data-anchor-id="https-support">https support</h3>
<p>Which methods have https support ?</p>
<ul>
<li>On windows: <em>“libcurl”</em> and <em>“wininet”</em></li>
<li>On non windows: <em>“libcurl”</em>, <em>“wget”</em> and <em>“curl”</em></li>
<li><em>“internal”</em> does not support https urls</li>
</ul>
</section>
<section class="section level3" id="http-https-redirection">
<h3 class="anchored" data-anchor-id="http-https-redirection">http &amp; https redirection</h3>
<ul>
<li>Only available with <em>“libcurl”</em> or <em>“wget”</em> by default</li>
<li>Possible for <em>“curl”</em> by adding a argument using <code>extra = -L</code></li>
<li><em>“wininet”</em> (windows only) supports some but not all</li>
</ul>
</section>
<section class="section level3" id="percent-decode-url">
<h3 class="anchored" data-anchor-id="percent-decode-url">percent decode url</h3>
<ul>
<li>not possible with method <em>“internal”</em>, <em>“wininet”</em> and <em>“wget”</em></li>
<li>possible with <em>“libcurl”</em> and <em>“curl”</em></li>
</ul>
</section>
<section class="section level3" id="percent-encode">
<h3 class="anchored" data-anchor-id="percent-encode">percent encode</h3>
<p>Most methods do not percent-encode special characters such as spaces in URLs
It seems the <em>“wininet”</em> method does.</p>
</section>
<section class="section level3" id="proxy-configuration">
<h3 class="anchored" data-anchor-id="proxy-configuration">Proxy configuration</h3>
<ul>
<li><p>For <em>“wininet”</em></p>
</li>
<li><p>No configuration required as the ‘Internet Options’ of the system are used.</p>
</li>
<li><p>They are defined in Control Panel and used by Internet Explorer</p>
</li>
<li><p>for <em>“internal”</em> only</p>
<ul>
<li>Proxies can be specified via environment variables
<ul>
<li><code>no_proxy = *</code> (stops any proxies being tried)</li>
<li><code>http_proxy</code> or <code>ftp_proxy</code></li>
<li>with form http://proxy.dom.com/ or http://proxy.dom.com:8080/</li>
</ul>
</li>
<li>authentification pass through environment variable <code>http_proxy_user</code> or <code>ftp_proxy_user</code> with the form <code>user:pwd</code>. It could also be set with the form <code>http_proxy =  http://user:pwd@proxy.dom.com:8080/</code></li>
</ul>
</li>
<li><p>for <em>“wget”</em> compatibility</p>
<ul>
<li><code>no_proxy</code>, <code>http_proxy</code>, <code>ftp_proxy</code> can be used</li>
<li>authentification pass through <code>http_proxy</code> with the form http://user:pwd@proxy.dom.com:8080/</li>
<li>not compatible with <code>http_proxy_user</code> and <code>ftp_proxy_user</code></li>
</ul>
</li>
<li><p>for <em>“libcurl”</em></p>
<ul>
<li><code>http_proxy</code> &amp; <code>ftp_proxy</code> can be used but the form is <code>[user:password@]machine[:port]</code></li>
<li>not compatible with <code>http_proxy_user</code> and <code>ftp_proxy_user</code></li>
</ul>
</li>
</ul>
</section>
<section class="section level3" id="about-wget-and-curl">
<h3 class="anchored" data-anchor-id="about-wget-and-curl">about <em>“wget”</em> and <em>“curl”</em> ?</h3>
<ul>
<li>Methods <em>“wget”</em> and <em>“curl”</em> are mainly for historical compatibility but provide may provide capabilities not supported by the <em>“libcurl”</em> or <em>“wininet”</em> methods.</li>
<li>Method <em>“wget”</em>
<ul>
<li>can be used with proxy firewalls which require user/password authentication if proper values are stored in the configuration file for wget</li>
<li>commonly installed on UNIX-alikes (not macOS). Windows binaries are available and can be installed</li>
</ul>
</li>
<li>Method <em>“curl”</em>
<ul>
<li>installed on MacOs an UNIX-alikes</li>
<li>Windows binaries are available too</li>
</ul>
</li>
</ul>
</section>
<section class="section level3" id="secure-url-and-libcurl">
<h3 class="anchored" data-anchor-id="secure-url-and-libcurl">Secure URL and Libcurl</h3>
<p>On windows <em>“libcurl”</em> is not always functionnal because the OS does not provide a suitable CA certificate bundle.</p>
<blockquote>
<p>This is an issue for method = “libcurl” on Windows, where the OS does not provide a suitable CA certificate bundle, so by default on Windows certificates are not verified. To turn verification on, set environment variable CURL_CA_BUNDLE to the path to a certificate bundle file, usually named ‘ca-bundle.crt’ or ‘curl-ca-bundle.crt’. (This is normally done for a binary installation of R, which installs ‘R_HOME/etc/curl-ca-bundle.crt’ and sets CURL_CA_BUNDLE to point to it if that environment variable is not already set.) For an updated certificate bundle, see http://curl.haxx.se/docs/sslcerts.html. Currently one can download a copy from https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt and set CURL_CA_BUNDLE to the full path to the downloaded file.</p>
</blockquote>
</section>
</section>
<section class="section level2" id="what-should-we-do-in-package-like-remotes">
<h2 class="anchored" data-anchor-id="what-should-we-do-in-package-like-remotes">What should we do in package like <code>remotes</code> ?</h2>
<p>It depends on what R version we want to support.</p>
<p>Since R 3.2.0, supports of https is possible with <em>“wininet”</em> on windows and <em>“libcurl”</em> for non windows. However it was not by default and should be set manually.</p>
<ul>
<li><em>“wininet”</em> set by default for download by <code>setInternet2()</code> on windows</li>
<li><em>“libcurl”</em> had to be chosen as download method on other platform
By default, since R 3.2.5, default method in <code>download.file()</code> can handle https url on platforms which supports them.</li>
<li>On windows it is handled by <em>“wininet”</em></li>
<li>On other platform by <em>“libcurl”</em> which must be available
By default, since R 3.3.0, all builds support https and by default.</li>
<li>On windows it is handled by <em>“wininet”</em></li>
<li>On other platform by <em>“libcurl”</em> which must be available</li>
<li><code>setInternet2()</code> is not used anymore</li>
</ul>
<ol type="1">
<li>For R &gt; = 3.3.0 : default method for <code>download.file()</code> handle https without anything else to be done</li>
<li>For 3.2.0 &lt;= R &lt; 3.3.0, method should be set to <em>“wininet”</em> on windows and <em>“libcurl”</em> if url is https</li>
<li>For R &lt; 3.2.0, https was not supported.</li>
</ol>
<p>So, we may not need <code>remotes::download_method</code> anymore or we may adapt it for older version.</p>
<section class="section level3" id="proxy-configuration-1">
<h3 class="anchored" data-anchor-id="proxy-configuration-1">Proxy configuration</h3>
<p>The only thing that changes is proxy configuration.</p>
<ul>
<li>On windows, <em>“wininet”</em> is the default and use Internet Option setting. Nothing to be done</li>
<li>On non-windows, proxy must be set with <code>http_proxy = [user:pwd@]machine[:port]</code> in order to work with <em>“libcurl”</em>. This form seems to be also compatible with other methods.</li>
</ul>
<p>We could point to <code>download.file</code> help page with a focus on <em>“libcurl”</em> configuration.</p>
</section>
</section>
</section>

]]></description>
<category>R</category>
<guid>https://cderv.dev/posts/2016-12-26-download-method/index.html</guid>
<pubDate>Mon, 26 Dec 2016 00:00:00 +0000</pubDate>
</item>
</channel>
</rss>
