<?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>kumulonimbus</title>
<link>https://kumulonimb.us/apuntes/</link>
<atom:link href="https://kumulonimb.us/apuntes/index.xml" rel="self" type="application/rss+xml"/>
<description>Jorge Saturno es investigador en calidad del aire y ciencia de los aerosoles.</description>
<image>
<url>https://kumulonimb.us/media/profile/kumulonimbus_default01.png</url>
<title>kumulonimbus</title>
<link>https://kumulonimb.us/apuntes/</link>
<height>82</height>
<width>144</width>
</image>
<generator>quarto-1.10.18</generator>
<lastBuildDate>Mon, 18 Nov 2024 23:00:00 GMT</lastBuildDate>
<item>
  <title>Analogías entre Git y la metrología</title>
  <dc:creator>Jorge Saturno</dc:creator>
  <link>https://kumulonimb.us/apuntes/Git-metrologia/</link>
  <description><![CDATA[ 





<section id="una-breve-introducción-a-git" class="level2">
<h2 class="anchored" data-anchor-id="una-breve-introducción-a-git">Una breve introducción a Git</h2>
<p>Git es un software de control de versiones que se utiliza comúnmente en el desarrollo de software. Al usar Git, no necesitamos guardar los documentos como distintas versiones completas de ellos mismos sino sólo los cambios que hicimos y un comentario sobre qué cambios se hicieron, quién los hizo y cuándo. Es decir, nos ahorramos esos famosos archivos <em>tesis_version_2.docx</em>, <em>tesis_version_final4.docx</em>, etc. Además, Git es colaborativo. Varias personas pueden trabajar en la línea de versiones y luego juntar los cambios en una nueva versión.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Nota
</div>
</div>
<div class="callout-body-container callout-body">
<p>Git no es GitHub. GitHub es un sitio/servicio web para almacenar archivos y sus distintas versiones usando Git. Existen otros servicios de este tipo como <a href="https://codeberg.org/">Codeberg</a>, <a href="https://about.gitlab.com/">GitLab</a> y <a href="https://about.gitea.com/">Gitea</a>. Puedes escoger cualquiera de ellos para hospedar tu repositorio en línea.</p>
</div>
</div>
<p>En un flujo de trabajo en Git, trabajamos en el documento o datos, hacemos los cambios que queremos hacer y luego de salvar hacemos un <em>commit</em>, que siginifica algo así como <em>acometer</em>. En este paso agregamos un comentario sobre qué fue lo que cambiamos en el archivo. Otra personas, o nosotras mismas, podemos comparar en el futuro cómo se ve el archivo antes y después de ese <em>commit</em> en un software que nos muestra las diferencias entre ambas versiones. Si nunca has usado Git, puede que los primeros pasos te resulten complicados pero realmente es sencillo de usar luego de aprender cómo funcionan los <a href="https://es.wikipedia.org/wiki/Git#%C3%93rdenes_b%C3%A1sicas">comandos básicos</a> que no son más de una decena.</p>
<p>Ahora, mi intención de escribir estas líneas es mostrar algunos paralelismos entre el mundo de la metrología (ciencia de las mediciones) y Git. Y esto viene inspirado por un <a href="https://www.youtube.com/watch?v=0OFRAadYsd4">webinar</a> que realmente recomiendo ver.</p>
</section>
<section id="analogías-entre-conceptos-de-metrología-y-de-git" class="level2">
<h2 class="anchored" data-anchor-id="analogías-entre-conceptos-de-metrología-y-de-git">Analogías entre conceptos de metrología y de Git</h2>
<p>Frédéric Tessier (NRC, Canada) comenta en el webinar que la mentalidad de las personas que trabajan en metrología ya es bastante cercana a la mentalidad que se necesita para trabajar con Git. La metrología se ocupa de mediciones y cómo éstas cambian en el tiempo, Git se ocupa de archivos y sus cambios en el tiempo. Acá una lista de los conceptos de metrología y sus equivalentes en el flujo de trabajo con Git:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 20%">
<col style="width: 79%">
</colgroup>
<thead>
<tr class="header">
<th>Metrología</th>
<th>Git</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Medida (un dato)</td>
<td>commit (un cambio)</td>
</tr>
<tr class="even">
<td>Exactitud</td>
<td>commit hash (identificación única de un commit)</td>
</tr>
<tr class="odd">
<td>Precisión</td>
<td>Cambios de hasta sólo un caracter son registrados</td>
</tr>
<tr class="even">
<td>Trazabilidad</td>
<td>log (Registro de cambios)</td>
</tr>
<tr class="odd">
<td>Comparabilidad</td>
<td>diff (Diferencias entre cambios)</td>
</tr>
<tr class="even">
<td>Reproducibilidad</td>
<td>clone (Capacidad de copiar y reproducir toda una cadena de cambios)</td>
</tr>
<tr class="odd">
<td>Responsabilidad</td>
<td>autoría del commit</td>
</tr>
<tr class="even">
<td>Documentación</td>
<td>descripción del commit</td>
</tr>
</tbody>
</table>
<p>Cada cambio en el tiempo va asignado a un <em>commit</em>, tal como una <strong>medida</strong> o un dato de alguna cantidad que se mida en un experimento. Los commits tienen a vez una etiqueta o <em>hash</em> asignado, el cual garantiza la <strong>exactitud</strong> del cambio al que se refiera y no otro similar o que haya ocurrido en otro momento. La <strong>precisión</strong> de los cambios va desde un carácter hasta la longitud que considere la persona que los ejecuta. La cadena de <em>logs</em>, o historia de commits, es un récord que garantiza la <strong>trazabilidad</strong> de los cambios hasta los archivos originales. Se pueden <strong>comparar</strong> los cambios uno a uno o en distintas etapas de la edición. De esta manera, se pueden identificar las diferencias entre distintas ramas de trabajo o entre distintas etapas del proyecto. Una cadena de cambios puede ser reproducida por terceras personas con tan sólo clonar el proyecto. Así se garantiza la <strong>reproducibilidad</strong> del trabajo y además, se facilitan la transparencia y el acceso abierto. Cada cambio además va documentado con datos de la persona responsable del mismo.</p>
<p>Por estas razones, Git es una herramienta no sólo útil sino necesaria en la metrología. Cuando nos ocupamos de mantener todos estos criterios en las mediciones tenemos la capacidad de también aplicarlos al manejo de archivos digitales. De hecho, hoy en día se podría decir que (todas) las mediciones (datos) se guardan en archivos en nuestras computadoras.</p>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Cómo citar</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{saturno2024,
  author = {Saturno, Jorge},
  title = {Analogías entre Git y la metrología},
  date = {2024-11-19},
  url = {https://kumulonimb.us/apuntes/Git-metrologia/},
  doi = {10.59350/gwc3a-6n717},
  langid = {es}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cita este trabajo como:</div><div id="ref-saturno2024" class="csl-entry quarto-appendix-citeas">
Saturno, Jorge. 2024. <span>“Analogías entre Git y la
metrología.”</span> November 19. <a href="https://doi.org/10.59350/gwc3a-6n717">https://doi.org/10.59350/gwc3a-6n717</a>.
</div></div></section></div> ]]></description>
  <category>git</category>
  <category>metrología</category>
  <guid>https://kumulonimb.us/apuntes/Git-metrologia/</guid>
  <pubDate>Mon, 18 Nov 2024 23:00:00 GMT</pubDate>
  <media:content url="https://kumulonimb.us/apuntes/Git-metrologia/img/featured.webp" medium="image" type="image/webp"/>
</item>
<item>
  <title>Visualización de la pandemia de COVID-19 en R</title>
  <dc:creator>Jorge Saturno</dc:creator>
  <link>https://kumulonimb.us/apuntes/covid-19/</link>
  <description><![CDATA[ 





<p>Probablemente sientes que estamos inundados con información sobre la evolución de la pandemia de COVID-19. Sin embargo, nada mejor que manejar los datos uno mismo y analizarlos desde distintos puntos de vista. Creo que siempre hay alguien que observará algo en los datos que se nos ha escapado a millones de observadores y creo que cualquier aporte en esta emergencia mundial es valioso. Aquí dejo algunos de los recursos que he estado usando en los últimos días para seguir la evolución de casos en el mundo, especialmente en Latinoamérica.</p>
<section id="de-dónde-vienen-los-datos" class="level2">
<h2 class="anchored" data-anchor-id="de-dónde-vienen-los-datos">De dónde vienen los datos</h2>
<p>La fuente de datos más completa de casos de COVID-19 es la que provee la Universidad John Hopkins (JHU) y que actualizan varias veces al día en su <a href="https://github.com/CSSEGISandData/COVID-19">repositorio</a> de GitHub. Estos datos son organizados por la universidad usando como fuentes la Organización Mundial de la Salud y fuentes nacionales (ministerios de salud y otras fuentes oficiales). Estos datos están divididos en tres archivos, los cuales contienen series de tiempo de casos confirmados, fallecidos y recuperados. Las tablas incluyen la localización hasta el nivel provincia/estado, con coordenadas geográficas. Desde el 22/03/2020, JHU dejó de reportar el número de recuperados.</p>
<p>A pesar de que podríamos cargar estos datos en R directamente desde el repositorio de la JHU, existen formas más cómodas de hacerlo. Actualmente existen dos paquetes de R que pueden hacerlo por nosotros.</p>
</section>
<section id="paquetes-de-r-dedicados-a-la-pandemia-de-covid-19" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="paquetes-de-r-dedicados-a-la-pandemia-de-covid-19">Paquetes de R dedicados a la pandemia de COVID-19</h2>
<p>Existe un par de paquetes de R de los que tengo conocimiento: <code>{coronavirus}</code> y <code>{nCov2019}</code>. He trabajado con ambos por varios días y puedo confirmar que ambos están siendo actualizados a diario (hasta el día de esta publicación).</p>
<section id="paquete-coronavirus" class="level3">
<h3 class="anchored" data-anchor-id="paquete-coronavirus">Paquete {coronavirus}</h3>
<p>El paquete <a href="https://ramikrispin.github.io/coronavirus/"><code>{coronavirus}</code></a> es desarrollado por <a href="https://ramikrispin.github.io/">Rami Krispin</a>, un científico de datos de California, Estados Unidos. Este paquete es muy práctico porque carga los datos de la Universidad John Hopkins y los ordena en formato tidy para ser usado en R fácilmente.</p>
<p>Para instalar este paquete:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">devtools<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">install_github</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RamiKrispin/coronavirus"</span>)</span></code></pre></div></div>
<p>Es necesario instalar el paquete de GitHub y no el disponible en CRAN para obtener los datos más actuales.</p>
<p>Una vista rápida a los datos provistos por este paquete:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(knitr)</span>
<span id="cb2-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(coronavirus), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">align =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span></code></pre></div></div>
<table class="caption-top table">
<colgroup>
<col style="width: 21%">
<col style="width: 21%">
<col style="width: 6%">
<col style="width: 8%">
<col style="width: 16%">
<col style="width: 9%">
<col style="width: 15%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: center;">Province.State</th>
<th style="text-align: center;">Country.Region</th>
<th style="text-align: center;">Lat</th>
<th style="text-align: center;">Long</th>
<th style="text-align: center;">date</th>
<th style="text-align: center;">cases</th>
<th style="text-align: center;">type</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;"></td>
<td style="text-align: center;">Afghanistan</td>
<td style="text-align: center;">33</td>
<td style="text-align: center;">65</td>
<td style="text-align: center;">2020-01-22</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">confirmed</td>
</tr>
<tr class="even">
<td style="text-align: center;"></td>
<td style="text-align: center;">Afghanistan</td>
<td style="text-align: center;">33</td>
<td style="text-align: center;">65</td>
<td style="text-align: center;">2020-01-23</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">confirmed</td>
</tr>
<tr class="odd">
<td style="text-align: center;"></td>
<td style="text-align: center;">Afghanistan</td>
<td style="text-align: center;">33</td>
<td style="text-align: center;">65</td>
<td style="text-align: center;">2020-01-24</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">confirmed</td>
</tr>
<tr class="even">
<td style="text-align: center;"></td>
<td style="text-align: center;">Afghanistan</td>
<td style="text-align: center;">33</td>
<td style="text-align: center;">65</td>
<td style="text-align: center;">2020-01-25</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">confirmed</td>
</tr>
<tr class="odd">
<td style="text-align: center;"></td>
<td style="text-align: center;">Afghanistan</td>
<td style="text-align: center;">33</td>
<td style="text-align: center;">65</td>
<td style="text-align: center;">2020-01-26</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">confirmed</td>
</tr>
<tr class="even">
<td style="text-align: center;"></td>
<td style="text-align: center;">Afghanistan</td>
<td style="text-align: center;">33</td>
<td style="text-align: center;">65</td>
<td style="text-align: center;">2020-01-27</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">confirmed</td>
</tr>
</tbody>
</table>
<p>Lo que más me ha gustado de este paquete, además del formato tidy, es que incorpora latitud y longitud de cada sitio y esto simplifica mucho las cosas.</p>
</section>
<section id="distribución-geográfica-de-los-casos-y-tasa-de-letalidad" class="level3 page-columns page-full">
<h3 class="anchored" data-anchor-id="distribución-geográfica-de-los-casos-y-tasa-de-letalidad">Distribución geográfica de los casos y tasa de letalidad</h3>
<p>Usando los datos disponibles podremos hacer un mapa de los casos acumulados hasta el momento y la tasa de letalidad.</p>
<p>Para calcular los casos acumulados y la tasa de letalidad:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(tidyverse)</span>
<span id="cb3-2"></span>
<span id="cb3-3">datacov <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> coronavirus <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> Country.Region, type, cases, Lat, Long) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(country, Lat, Long, type) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_cases =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cases)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_wider</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_from =</span> type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_from =</span> total_cases) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>confirmed) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">deadRate =</span> death<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>confirmed <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span></code></pre></div></div>
<p>Con estos datos organizados podemos graficar el mapa de la siguiente forma:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(maps, hrbrthemes, viridis)</span>
<span id="cb4-2"></span>
<span id="cb4-3">fecha <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(coronavirus<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>date), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%d/%m/%Y"</span>)</span>
<span id="cb4-4">mundo <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_data</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"world"</span>)</span>
<span id="cb4-5">cortes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5000</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10000</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30000</span>)</span>
<span id="cb4-6"></span>
<span id="cb4-7">p1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_polygon</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> mundo, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x=</span>long, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> lat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey50"</span>,</span>
<span id="cb4-9">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> datacov, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x=</span>Long, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y=</span>Lat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size=</span>confirmed, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color=</span>deadRate),</span>
<span id="cb4-11">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stroke=</span>F, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_size_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Casos"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">range=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>),<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks=</span>cortes,</span>
<span id="cb4-13">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1-19"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"20-99"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"100-999"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1.000-4.999"</span>,</span>
<span id="cb4-14">                                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"5.000-9.999"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10.000-29.999"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"30.000+"</span>)</span>
<span id="cb4-15">                                     ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_viridis</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">option=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"magma"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tasa de letalidad (%)"</span>,</span>
<span id="cb4-17">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">limits=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Casos de COVID-19 al "</span>, fecha),</span>
<span id="cb4-19">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Número de casos y tasa de letalidad"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_ipsum_rc</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grid =</span> F) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb4-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb4-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb4-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb4-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>()</span>
<span id="cb4-26">  )</span>
<span id="cb4-27"></span>
<span id="cb4-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p1)</span></code></pre></div></div>
<div class="quarto-figure quarto-figure-center page-columns page-full">
<figure class="figure page-columns page-full">
<p><img src="https://kumulonimb.us/apuntes/covid-19/img/COVID19_mapa_20200327.png" class="img-fluid figure-img"></p>
<figcaption class="margin-caption">Mapa de casos de COVID-19 al 27/03/2020 usando datos provistos por el paquete de R <code>{coronavirus}</code></figcaption>
</figure>
</div>
<p>Cabe destacar que la tasa de letalidad puede ser una cifra engañosa, ya que no todos los países están diagnosticando el COVID-19 de la misma forma y la gran mayoría de los países reportan menos números de casos de los que realmente existen. Este <a href="https://cmmid.github.io/topics/covid19/severity/global_cfr_estimates.html">estudio</a> muestra el porcentaje de casos que están reportando varios países, casi todos por debajo del 50 %.</p>
</section>
<section id="paquete-ncov2019" class="level3">
<h3 class="anchored" data-anchor-id="paquete-ncov2019">Paquete {nCov2019}</h3>
<p>El paquete <a href="https://guangchuangyu.github.io/nCov2019/"><code>{nCov2019}</code></a> es desarrollado por <a href="https://github.com/GuangchuangYu">Guangchuang Yu</a>, un profesor de bioinformática de la Universidad Médica del Sur, en Guangzhou, China. Este paquete provee varios sets de datos con distintos niveles de resolución geográfica, uno <em>global</em> donde se detallan los casos por países, hasta uno más detallado que llega a escala de ciudades. Es un paquete muy bien organizado pero le encuentro dos detalles que no me han gustado: no viene en formato tidy (esto es cuestión de gustos) y no provee las coordenadas geográficas. Esto último se puede resolver usando <code>ggmap::geocode</code>, función con la cual se pueden obtener las coordenadas de las ciudades desde <em>Google Maps</em>. En este caso, se requiere de una Google API key.</p>
<p>Desde este paquete he extraído los datos de casos en países latinoamericanos y he calculado la cantidad de casos confirmados a partir del día en que cada país sobrepasó los 100 casos:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(tidyverse)</span>
<span id="cb5-2"></span>
<span id="cb5-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Países latinos</span></span>
<span id="cb5-4">latinos <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Argentina"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Bolivia"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brazil"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Chile"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Colombia"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Costa Rica"</span>,</span>
<span id="cb5-5">             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Cuba"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ecuador"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"El Salvador"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Guatemala"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Haiti"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Honduras"</span>,</span>
<span id="cb5-6">             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mexico"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Nicaragua"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Panama"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Paraguay"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Peru"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dominican Republic"</span>,</span>
<span id="cb5-7">             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Uruguay"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Venezuela"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Puerto Rico"</span>)</span>
<span id="cb5-8"></span>
<span id="cb5-9">d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">load_nCov2019</span>() <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Carga los datos más recientes</span></span>
<span id="cb5-10">dd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> d[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'global'</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-11">  as_tibble <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">confirm=</span>cum_confirm) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(confirm <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> latinos) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(country) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">days_since_100 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(time <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(time))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-16">  ungroup</span>
<span id="cb5-17"></span></code></pre></div></div>
<p>Para cambiar los nombres de los países a español (en los que se requiere):</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">dd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dd <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Peru"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Perú"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dominican Republic"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rep. Dominicana"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brazil"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brasil"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Haiti"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Haití"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Panama"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Panamá"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mexico"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"México"</span>, country))</span></code></pre></div></div>
<p>Un vistazo a los datos muestra lo siguiente:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(dd, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">align =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span></code></pre></div></div>
<table class="caption-top table">
<colgroup>
<col style="width: 16%">
<col style="width: 22%">
<col style="width: 12%">
<col style="width: 13%">
<col style="width: 13%">
<col style="width: 21%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: center;">time</th>
<th style="text-align: center;">country</th>
<th style="text-align: center;">confirm</th>
<th style="text-align: center;">cum_heal</th>
<th style="text-align: center;">cum_dead</th>
<th style="text-align: center;">days_since_100</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">2020-03-14</td>
<td style="text-align: center;">Brasil</td>
<td style="text-align: center;">151</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
</tr>
<tr class="even">
<td style="text-align: center;">2020-03-15</td>
<td style="text-align: center;">Brasil</td>
<td style="text-align: center;">151</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">1</td>
</tr>
<tr class="odd">
<td style="text-align: center;">2020-03-16</td>
<td style="text-align: center;">Brasil</td>
<td style="text-align: center;">203</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">2</td>
</tr>
<tr class="even">
<td style="text-align: center;">2020-03-17</td>
<td style="text-align: center;">Brasil</td>
<td style="text-align: center;">234</td>
<td style="text-align: center;">2</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">3</td>
</tr>
<tr class="odd">
<td style="text-align: center;">2020-03-17</td>
<td style="text-align: center;">Chile</td>
<td style="text-align: center;">156</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
</tr>
<tr class="even">
<td style="text-align: center;">2020-03-18</td>
<td style="text-align: center;">Brasil</td>
<td style="text-align: center;">349</td>
<td style="text-align: center;">2</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">4</td>
</tr>
<tr class="odd">
<td style="text-align: center;">2020-03-18</td>
<td style="text-align: center;">Chile</td>
<td style="text-align: center;">201</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">1</td>
</tr>
<tr class="even">
<td style="text-align: center;">2020-03-18</td>
<td style="text-align: center;">Ecuador</td>
<td style="text-align: center;">111</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">2</td>
<td style="text-align: center;">0</td>
</tr>
</tbody>
</table>
<p>La variable <em>confirm</em> muestra casos confirmados acumulados hasta la fecha.</p>
</section>
<section id="evolución-de-casos-en-latinoamérica-y-tiempo-de-duplicación" class="level3 page-columns page-full">
<h3 class="anchored" data-anchor-id="evolución-de-casos-en-latinoamérica-y-tiempo-de-duplicación">Evolución de casos en Latinoamérica y tiempo de duplicación</h3>
<p>Antes de mostrar la serie de tiempo de los casos confirmados en cada país calculamos el crecimiento exponencial asumiendo dos escenarios: 1) duplicación de casos cada 2 días, y 2) duplicación de casos cada 3 días.</p>
<p>Partiendo de la siguiente ecuación de crecimiento exponencial:</p>
<p><img src="https://latex.codecogs.com/png.latex?%20N_t%20=%20N_0%20e%5E%7Brt%7D%20%5C%20"></p>
<p>donde <img src="https://latex.codecogs.com/png.latex?N_t"> es el número de casos en un tiempo <img src="https://latex.codecogs.com/png.latex?t%20%3E%200">, <img src="https://latex.codecogs.com/png.latex?N_0"> es el número de casos iniciales (aquí usamos un inicio de 100 casos, <img src="https://latex.codecogs.com/png.latex?N_0%20=%20100">) y <img src="https://latex.codecogs.com/png.latex?r"> es la tasa media de crecimiento.</p>
<p>El tiempo de duplicación se define como el tiempo en que el número de casos se duplica, es decir:</p>
<p><img src="https://latex.codecogs.com/png.latex?%202N_0%20=%20N_0%20e%5E%7Brt%7D%20%5C%20"></p>
<p>de aquí se obtiene que</p>
<p><img src="https://latex.codecogs.com/png.latex?%20e%5E%7Brt%7D%20=%202%20%5C%20"></p>
<p>al tomar logaritmo natural de ambos lados, se obtiene:</p>
<p><img src="https://latex.codecogs.com/png.latex?%20rt%20=%20log(2)%20%5C%20"></p>
<p>por lo tanto, el tiempo de duplicación vendría siendo</p>
<p><img src="https://latex.codecogs.com/png.latex?%20t_%7Bdupl%7D%20=%20log(2)%20/%20r%20%5C%20"></p>
<p>Usando estas ecuaciones podemos definir funciones para la duplicación de casos en dos y tres días, respectivamente:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">dup2dias <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x)<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>x)</span>
<span id="cb8-2">dup3dias <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x)<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>x)</span></code></pre></div></div>
<p>En el gráfico a continuación, los datos de la evolución de casos en Latinoamérica son comparados con las curvas de crecimiento exponencial calculadas con las funciones anteriores. Las curvas artificiales son agregadas usando <code>stat_function</code>.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(hrbrthemes, ggrepel)</span>
<span id="cb9-2"></span>
<span id="cb9-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Obtener valores máximos y fecha</span></span>
<span id="cb9-4">fecha2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(dd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%d/%m/%Y"</span>)</span>
<span id="cb9-5">dd_today <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dd[dd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> fecha2,]</span>
<span id="cb9-6">dd_max_confirm <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(dd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>confirm)</span>
<span id="cb9-7">dd_max_days <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(dd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>days_since_100)</span>
<span id="cb9-8"></span>
<span id="cb9-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Crear etiquetas para las curvas de predicción</span></span>
<span id="cb9-10">etiquetas_curvas <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb9-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">etiq =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Se duplica </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">cada 2 días"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Se duplica </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">cada 3 días"</span>),</span>
<span id="cb9-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(dd_max_days <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, dd_max_days),</span>
<span id="cb9-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(dd_today<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>confirm), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dup3dias</span>(dd_max_days)),</span>
<span id="cb9-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"xxx"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yyy"</span>)</span>
<span id="cb9-15">)</span>
<span id="cb9-16"></span>
<span id="cb9-17">p2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(dd, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(days_since_100, confirm, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dd_today, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> cum_dead)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_function</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fun=</span>dup2dias, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey20"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_function</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fun=</span>dup3dias, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey20"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_size</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Total </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">fallecidos"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">add =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">limits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, dd_max_confirm)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_ipsum_rc</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle_family =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Roboto Condensed"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb9-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid.minor =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb9-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid.major.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb9-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"right"</span>,</span>
<span id="cb9-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.margin =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">margin</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm"</span>),</span>
<span id="cb9-31">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">guides</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_cartesian</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">clip =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"off"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text_repel</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dd_today, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> country), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,</span>
<span id="cb9-35">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Roboto Condensed"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">force =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg.color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>,</span>
<span id="cb9-36">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">segment.color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey80"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-37">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> etiquetas_curvas, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#FFFFFF00"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-38">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text_repel</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> etiquetas_curvas, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> etiq),</span>
<span id="cb9-39">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey20"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">point.padding =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb9-40">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Roboto Condensed"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-41">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Número de días desde el caso 100"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb9-42">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"COVID-19 en Latinoamérica"</span>,</span>
<span id="cb9-43">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Evolución de casos confirmados al "</span>, fecha2))</span>
<span id="cb9-44"></span>
<span id="cb9-45"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p2)</span></code></pre></div></div>
<div class="quarto-figure quarto-figure-center page-columns page-full">
<figure class="figure page-columns page-full">
<p><img src="https://kumulonimb.us/apuntes/covid-19/img/COVID19_casos_latam.png" class="img-fluid figure-img"></p>
<figcaption class="margin-caption">Evolución de casos de COVID-19 en Latinoamérica comparados con curvas de duplicación de casos cada dos y tres días</figcaption>
</figure>
</div>
<p>Es de esperarse que las medidas de confinamiento lleven a estas curvas a disminuir su velocidad de crecimiento y a estar muy por debajo de la curva de duplicación cada 3 días. Espero que eso ocurra pronto. Mientras tanto, evita el contacto físico fuera de tu círculo familiar, cuida de tu salud y sé solidario con tus vecinos.</p>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Importante
</div>
</div>
<div class="callout-body-container callout-body">
<p>Esta no es una fuente oficial de información sobre la pandemia de COVID-19. Para consultas y referencias visite el <a href="https://www.who.int/es/emergencies/diseases/novel-coronavirus-2019">sitio oficial de la Organización Mundial de la Salud</a>.</p>
</div>
</div>


</section>
</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Cómo citar</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{saturno2020,
  author = {Saturno, Jorge},
  title = {Visualización de la pandemia de COVID-19 en R},
  date = {2020-03-28},
  url = {https://kumulonimb.us/apuntes/covid-19/},
  doi = {10.59350/cy2ac-2nb93},
  langid = {es}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cita este trabajo como:</div><div id="ref-saturno2020" class="csl-entry quarto-appendix-citeas">
Saturno, Jorge. 2020. <span>“Visualización de la pandemia de COVID-19 en
R.”</span> March 28. <a href="https://doi.org/10.59350/cy2ac-2nb93">https://doi.org/10.59350/cy2ac-2nb93</a>.
</div></div></section></div> ]]></description>
  <category>covid-19</category>
  <category>r</category>
  <category>leaflet</category>
  <category>pandemia</category>
  <guid>https://kumulonimb.us/apuntes/covid-19/</guid>
  <pubDate>Fri, 27 Mar 2020 23:00:00 GMT</pubDate>
  <media:content url="https://kumulonimb.us/apuntes/covid-19/img/featured.webp" medium="image" type="image/webp"/>
</item>
<item>
  <title>Mapas con {leaflet} en R</title>
  <dc:creator>Jorge Saturno</dc:creator>
  <link>https://kumulonimb.us/apuntes/leaflet/</link>
  <description><![CDATA[ 





<p><em>Leaflet</em> es una biblioteca de <i class="fa-brands fa-js" aria-label="js"></i> Javascript para hacer mapas y existe un paquete homónimo para <i class="fa-brands fa-r-project" aria-label="r-project"></i> que permite usar todo el potencial de <em>leaflet</em> en nuestros mapas y hacerlos interactivos y aptos para móviles.</p>
<p>Para crear un mapa en blanco se usa la función <code>leaflet</code>. La función <code>addTiles()</code> agrega “tiles” de OpenStreetMap.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(leaflet)</span>
<span id="cb1-2"></span>
<span id="cb1-3">m0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leaflet</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb1-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addTiles</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb1-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setView</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span> , <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">zoom=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Centrar el mapa en Suramérica</span></span>
<span id="cb1-6"></span>
<span id="cb1-7">m0 <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Visualizar el mapa</span></span></code></pre></div></div>
     <div>
      <iframe src="media/leaflet/leaflet_m0.html" height="600px"></iframe>
    </div>
  
<section id="arreglar-el-zoom-out-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c206661206d61676e696679696e672d676c6173732d6d696e7573203e7d7d" class="level2">
<h2 class="anchored" data-anchor-id="arreglar-el-zoom-out-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c206661206d61676e696679696e672d676c6173732d6d696e7573203e7d7d">Arreglar el “zoom-out” <i class="fa-solid fa-magnifying-glass-minus" aria-label="magnifying-glass-minus"></i></h2>
<p>Uno de los problemas que más pueden fastidiar al crear un mapa de <em>leaflet</em> es que al hacer <em>zoom-out</em> <i class="fa-solid fa-magnifying-glass-minus" aria-label="magnifying-glass-minus"></i> se pueden llegar a ver “varios” planetas Tierra, lo cual no tiene mucho sentido. Esto se puede arreglar definiendo límites al hacer <em>zoom-out</em> <i class="fa-solid fa-magnifying-glass-minus" aria-label="magnifying-glass-minus"></i> y <em>zoom-in</em> <i class="fa-solid fa-magnifying-glass-plus" aria-label="magnifying-glass-plus"></i>. Se pueden cambiar las opciones de la función <code>leaflet</code>. Un ejemplo es el siguiente:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(leaflet)</span>
<span id="cb2-2"></span>
<span id="cb2-3">m0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leaflet</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leafletOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">minZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb2-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addTiles</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb2-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setView</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span> , <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">zoom=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Centrar el mapa en Suramérica</span></span>
<span id="cb2-6"></span>
<span id="cb2-7">m0</span></code></pre></div></div>
     <div>
      <iframe src="media/leaflet/leaflet_m0_zoom.html" height="600px"></iframe>
    </div>
  
<p>En este caso, iniciamos con un zoom a nivel 4, definido en <code>setView</code>, y sólo permitimos bajar un nivel más (3) y llegar a un máximo de 8. Estos límites serán mejor definidos al crear y visualizar el mapa y dependerán de la aplicación que se le quiera dar. Para dejar el mapa en un zoom fijo y no permitir <em>zoom-out</em> ni <em>zoom-in</em>, se pueden fijar <code>minZoom</code> y <code>maxZoom</code> al mismo nivel.</p>
</section>
<section id="cambiar-el-estilo-del-mapa-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c206661206272757368203e7d7d" class="level2">
<h2 class="anchored" data-anchor-id="cambiar-el-estilo-del-mapa-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c206661206272757368203e7d7d">Cambiar el estilo del mapa <i class="fa-solid fa-brush" aria-label="brush"></i></h2>
<p>Además de las capas de OpenStreetMap usadas por defecto en <em>leaflet</em>, existen muchas otras disponibles. Una lista de diferentes estilos/capas se puede encontrar <a href="http://leaflet-extras.github.io/leaflet-providers/preview/index.html">aquí</a>. Uno de mis temas favoritos es <em>Positron</em> de <a href="https://github.com/CartoDB/basemap-styles"><strong>CartoDB</strong></a>. Este mapa se puede cargar de la siguiente manera:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">m0_positron <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leaflet</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leafletOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">minZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addProviderTiles</span>(providers<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>CartoDB.Positron) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setView</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span> , <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">zoom=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb3-4"></span>
<span id="cb3-5">m0_positron</span></code></pre></div></div>
     <div>
      <iframe src="media/leaflet/leaflet_m0_positron.html" height="600px"></iframe>
    </div>
  
<p>También se puede cargar sin las etiquetas usando <code>addProviderTiles(providers$CartoDB.PositronNoLabels)</code>.</p>
     <div>
      <iframe src="media/leaflet/leaflet_m0_sin_etiq.html" height="600px"></iframe>
    </div>
  
<p><strong>CartoDB</strong> también provee un tema oscuro que puede ser usado de igual forma con o sin etiquetas: <code>addProviderTiles(providers$CartoDB.DarkMatter)</code> o <code>addProviderTiles(providers$CartoDB.DarkMatterNoLabels)</code>, respectivamente.</p>
<p>Acá una visualización del tema oscuro sin etiquetas:</p>
     <div>
      <iframe src="media/leaflet/leaflet_m0_oscuro.html" height="600px"></iframe>
    </div>
  
</section>
<section id="agregar-datos-al-mapa-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c206661206461746162617365203e7d7d" class="level2">
<h2 class="anchored" data-anchor-id="agregar-datos-al-mapa-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c206661206461746162617365203e7d7d">Agregar datos al mapa <i class="fa-solid fa-database" aria-label="database"></i></h2>
<p>Para este ejemplo vamos a agregar datos del paquete <a href="https://github.com/RamiKrispin/coronavirus"><code>{coronavirus}</code></a>. Más detalles sobre el uso de estos datos se pueden conseguir en esta <a href="{{< ref &quot;/post/coronavirus-r/index.md&quot; >}}">otra entrada</a>. Para cargar estos datos hacemos lo siguiente:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Cargar datos</span></span>
<span id="cb4-2"></span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Para instalar el paquete {coronavirus}:</span></span>
<span id="cb4-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># devtools::install_github("RamiKrispin/coronavirus")</span></span>
<span id="cb4-5"></span>
<span id="cb4-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(coronavirus)</span>
<span id="cb4-7"></span>
<span id="cb4-8">datacov <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> coronavirus <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-9">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Seleccionar datos de interés</span></span>
<span id="cb4-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> Country.Region, type, cases, Lat, Long) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-11">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Agrupar por país</span></span>
<span id="cb4-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(country, Lat, Long, type) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-13">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Totalizar los casos</span></span>
<span id="cb4-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_cases =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cases)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-15">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Crear columnas para cada tipo de caso</span></span>
<span id="cb4-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_wider</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_from =</span> type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_from =</span> total_cases) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-17">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Ordenar por número de casos confirmados</span></span>
<span id="cb4-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>confirmed) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>()</span>
<span id="cb4-20"></span>
<span id="cb4-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Cambios los nombres a español</span></span>
<span id="cb4-22">datacov <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> datacov <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Peru"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Perú"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dominican Republic"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"República Dominicana"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brazil"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brasil"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Haiti"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Haití"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Panama"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Panamá"</span>, country)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">country =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(country <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mexico"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"México"</span>, country))</span></code></pre></div></div>
<p>Usando la función <code>addCircleMarkers()</code>, se puede graficar la variable <em>confirmed</em> (número de casos confirmados) sobre el mapa, usando el logaritmo del número de casos para definir el radio de los círculos graficados. Latitud y longitud están incluidos en los datos en las variables <code>Long</code> y <code>Lat</code>. Usando el parámetro <code>popup</code> se puede crear una caja de información con datos a ser mostrados al hace click en cada círculo. En este caso se agrega el nombre del país y número de casos confirmados y fallecidos.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">m1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leaflet</span>(datacov, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leafletOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">minZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addProviderTiles</span>(providers<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>CartoDB.PositronNoLabels) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addCircleMarkers</span>(</span>
<span id="cb5-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Long,</span>
<span id="cb5-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Lat,</span>
<span id="cb5-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb5-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">radius =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(confirmed)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Adaptar según se desee</span></span>
<span id="cb5-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ff7761"</span>,</span>
<span id="cb5-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stroke =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fillOpacity =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>,</span>
<span id="cb5-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">popup =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>country, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;br&gt;"</span>,</span>
<span id="cb5-11">                  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;b&gt;Casos confirmados: &lt;/b&gt;"</span>, datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>confirmed, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;br&gt;"</span>,</span>
<span id="cb5-12">                  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;b&gt;Fallecidos: &lt;/b&gt;"</span>, datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>death)</span>
<span id="cb5-13">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setView</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span> , <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">zoom=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb5-15"></span>
<span id="cb5-16">m1</span></code></pre></div></div>
     <div>
      <iframe src="media/leaflet/leaflet_m1.html" height="600px"></iframe>
    </div>
  
<p>En el siguiente ejemplo se incluye una nueva capa con el número de fallecidos, la cual estará debajo de la de número de casos confirmados para garantizar que el área cliqueable siga activa en el círculo más grande.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">m2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leaflet</span>(datacov, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leafletOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">minZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addProviderTiles</span>(providers<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>CartoDB.PositronNoLabels) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addCircleMarkers</span>(</span>
<span id="cb6-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Long,</span>
<span id="cb6-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Lat,</span>
<span id="cb6-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb6-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">radius =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(death),</span>
<span id="cb6-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#881600"</span>,</span>
<span id="cb6-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stroke =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fillOpacity =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>,</span>
<span id="cb6-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addCircleMarkers</span>(</span>
<span id="cb6-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Long,</span>
<span id="cb6-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Lat,</span>
<span id="cb6-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb6-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">radius =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(confirmed)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb6-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ff7761"</span>,</span>
<span id="cb6-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stroke =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fillOpacity =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>,</span>
<span id="cb6-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">popup =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>country, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;br&gt;"</span>,</span>
<span id="cb6-19">                  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;b&gt;Casos confirmados: &lt;/b&gt;"</span>, datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>confirmed, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;br&gt;"</span>,</span>
<span id="cb6-20">                  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;b&gt;Fallecidos: &lt;/b&gt;"</span>, datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>death)</span>
<span id="cb6-21">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setView</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span> , <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">zoom=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb6-23"></span>
<span id="cb6-24">m2</span></code></pre></div></div>
     <div>
      <iframe src="media/leaflet/leaflet_m2.html" height="600px"></iframe>
    </div>
  
</section>
<section id="mostrar-etiquetas-al-desplazar-el-cursor-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c206661206172726f772d706f696e746572203e7d7d" class="level2">
<h2 class="anchored" data-anchor-id="mostrar-etiquetas-al-desplazar-el-cursor-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c206661206172726f772d706f696e746572203e7d7d">Mostrar etiquetas al desplazar el cursor <i class="fa-solid fa-arrow-pointer" aria-label="arrow-pointer"></i></h2>
<p>Para mostrar información al desplazar el cursor sobre los círculos, se puede usar el argumento <code>label</code> dentro de la función <code>addCircleMarkers()</code>. Una etiqueta con información del país y la cantidad de casos confirmados se agrega usando el siguiente parámetro:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>country),<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" | Casos confirmados: "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>confirmed)),</span></code></pre></div></div>
<section id="personalizar-las-etiquetas" class="level3">
<h3 class="anchored" data-anchor-id="personalizar-las-etiquetas">Personalizar las etiquetas</h3>
<p>Estas etiquetas pueden ser personalizadas usando el argumento <code>labelOptions</code>. En el siguiente mapa se agregan las etiquetas anteriores y se hacen algunos cambios a los colores y la tipografía de las mismas:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">m3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leaflet</span>(datacov, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">leafletOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">minZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxZoom =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addTiles</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addProviderTiles</span>(providers<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>CartoDB.PositronNoLabels) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addCircleMarkers</span>(</span>
<span id="cb8-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Long,</span>
<span id="cb8-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Lat,</span>
<span id="cb8-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb8-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">radius =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(death),</span>
<span id="cb8-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#881600"</span>,</span>
<span id="cb8-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stroke =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fillOpacity =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>,</span>
<span id="cb8-11">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addCircleMarkers</span>(</span>
<span id="cb8-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Long,</span>
<span id="cb8-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>Lat,</span>
<span id="cb8-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb8-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">radius =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(confirmed)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb8-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ff7761"</span>,</span>
<span id="cb8-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stroke =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fillOpacity =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>,</span>
<span id="cb8-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">popup =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>country, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;br&gt;"</span>,</span>
<span id="cb8-20">                  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;b&gt;Casos confirmados: &lt;/b&gt;"</span>, datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>confirmed, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;br&gt;"</span>,</span>
<span id="cb8-21">                  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;b&gt;Fallecidos: &lt;/b&gt;"</span>, datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>death),</span>
<span id="cb8-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>country),<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" | Casos confirmados: "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(datacov<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>confirmed)),</span>
<span id="cb8-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labelOptions =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labelOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">style =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb8-24">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"color"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#FFFFF3"</span>,</span>
<span id="cb8-25">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"font-family"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Roboto"</span>,</span>
<span id="cb8-26">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"font-weight"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>,</span>
<span id="cb8-27">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"box-shadow"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"3px 3px rgba(0,0,0,0.25)"</span>,</span>
<span id="cb8-28">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"font-size"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"16px"</span>,</span>
<span id="cb8-29">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background-color"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#566270"</span>,</span>
<span id="cb8-30">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"border-color"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rgba(0,0,0,0.5)"</span>))</span>
<span id="cb8-31">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setView</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lng=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lat=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span> , <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">zoom=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb8-33"></span>
<span id="cb8-34">m3</span></code></pre></div></div>
     <div>
      <iframe src="media/leaflet/leaflet_m3.html" height="600px"></iframe>
    </div>
  
</section>
<section id="personalizar-las-cajas-popup" class="level3">
<h3 class="anchored" data-anchor-id="personalizar-las-cajas-popup">Personalizar las cajas <em>popup</em></h3>
<p>La información mostrada en las cajas <em>popup</em> que aparecen al hacer click también puede ser personalizada. Sin embargo, el paquete <code>{leaflet}</code> es bastante limitado en este aspecto. Una forma de modificar el estilo a gusto es usando la función <code>browsable()</code> del paquete <code>{htmltools}</code>. Un ejemplo usando el mapa generado anteriormente es el siguiente:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">browsable</span>(</span>
<span id="cb9-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tagList</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb9-3">    tags<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(</span>
<span id="cb9-4">      tags<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">style</span>(</span>
<span id="cb9-5">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".leaflet-popup-content-wrapper {</span></span>
<span id="cb9-6"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        background: black;</span></span>
<span id="cb9-7"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        color: #ffffff;</span></span>
<span id="cb9-8"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        font-size: 15px;</span></span>
<span id="cb9-9"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        padding: 2px;</span></span>
<span id="cb9-10"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        border-radius: 0px;</span></span>
<span id="cb9-11"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        }"</span></span>
<span id="cb9-12">      )</span>
<span id="cb9-13">    ),</span>
<span id="cb9-14">    m3</span>
<span id="cb9-15">  ))</span>
<span id="cb9-16">)</span></code></pre></div></div>
</section>
</section>
<section id="guardar-y-publicar-el-mapa-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c20666120666c6f7070792d6469736b203e7d7d" class="level2">
<h2 class="anchored" data-anchor-id="guardar-y-publicar-el-mapa-b58fc729-690b-4000-b19f-365a4093b2ff7b7b3c20666120666c6f7070792d6469736b203e7d7d">Guardar y publicar el mapa <i class="fa-solid fa-floppy-disk" aria-label="floppy-disk"></i></h2>
<p>El resultado se puede guardar como un archivo html usando el paquete <code>{htmlwidgets}</code>.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(htmlwidgets)</span>
<span id="cb10-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">saveWidget</span>(m3, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"~/leaflet_m3.html"</span>)</span></code></pre></div></div>
<p>Este archivo html se puede subir e incrustar en un sitio web usando el siguiente código:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode html code-with-copy"><code class="sourceCode html"><span id="cb11-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">&lt;</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">iframe</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> src</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"leaflet_m0.html"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> frameborder</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> width</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"100%"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> height</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"600px"</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">&gt;&lt;/</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">iframe</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">&gt;</span></span></code></pre></div></div>
<section id="publicar-en-un-sitio-web-hugo" class="level3">
<h3 class="anchored" data-anchor-id="publicar-en-un-sitio-web-hugo">Publicar en un sitio web Hugo</h3>
<p>Para publicar en un sitio estático de hugo se puede agregar un nuevo <em>shortcode</em> en <code>/layouts/partials/shortcodes</code>. Esto se hace creando un nuevo archivo en ese directorio, al cual, en este caso, llamaremos <code>hp5.html</code>. El contenido de dicho archivo sería el siguiente:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode html code-with-copy"><code class="sourceCode html"><span id="cb12-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">&lt;</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">iframe</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> src</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"{{.Get 0}}"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> width</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"100%"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> height</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"{{.Get 1}}"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> frameborder</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> allowfullscreen</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"allowfullscreen"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;"> allow</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"geolocation *; microphone *; camera *; midi *; encrypted-media *"</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">&gt;&lt;/</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">iframe</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">&gt;</span></span></code></pre></div></div>
<p>Aquí se define la forma en que se mostrará el mapa. En este caso, con un ancho de “100%” y una altura variable en píxeles. El <em>shortcode</em> hp5, tal como está definido, requerirá dos parámetros: 1. localización del archivo y 2. altura (<em>height</em>) del mapa a ser mostrado.</p>
<p>Una vez definido el <em>shortcode</em>, podemos usarlo en cualquier publicación de hugo para mostrar el mapa creado y mostrarlo con un altura de <code>"600"</code> píxeles. Como se muestra en este ejemplo:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb13-1">{{&lt; hp5 "/leaflet/leaflet_m0.html" "600"&gt;}}</span></code></pre></div></div>
<p>¡Feliz mapeo!</p>


</section>
</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Cómo citar</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{saturno2019,
  author = {Saturno, Jorge},
  title = {Mapas con \{leaflet\} en R},
  date = {2019-04-25},
  url = {https://kumulonimb.us/apuntes/leaflet/},
  doi = {10.59350/3jb6r-c1g06},
  langid = {es}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cita este trabajo como:</div><div id="ref-saturno2019" class="csl-entry quarto-appendix-citeas">
Saturno, Jorge. 2019. <span>“Mapas con {leaflet} en R.”</span> April 25.
<a href="https://doi.org/10.59350/3jb6r-c1g06">https://doi.org/10.59350/3jb6r-c1g06</a>.
</div></div></section></div> ]]></description>
  <category>r</category>
  <category>rstudio</category>
  <category>leaflet</category>
  <category>mapeo</category>
  <guid>https://kumulonimb.us/apuntes/leaflet/</guid>
  <pubDate>Wed, 24 Apr 2019 22:00:00 GMT</pubDate>
  <media:content url="https://kumulonimb.us/apuntes/leaflet/img/featured.webp" medium="image" type="image/webp"/>
</item>
<item>
  <title>RStudio en Manjaro Linux</title>
  <dc:creator>Jorge Saturno</dc:creator>
  <link>https://kumulonimb.us/apuntes/RStudio/</link>
  <description><![CDATA[ 





<p><a href="https://www.rstudio.com/">RStudio</a> es el entorno de desarrollo para R más popular hoy en día. Su instalación en Manjaro (y otras distribuciones basadas en Arch Linux) es muy sencilla pero requiere usar el repositorio mantenidos por los usuarios, conocido como Arch User Repository (AUR). Usualmente, se usaba <em>yaourt</em> para instalar paquetes del AUR pero dado que este fue descontinuado, tendremos que instalar <em>yay</em>, uno de sus sustitutos.</p>
<section id="instalar-yay" class="level2">
<h2 class="anchored" data-anchor-id="instalar-yay">Instalar <em>yay</em></h2>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> clone https://aur.archlinux.org/yay.git</span>
<span id="cb1-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> yay</span>
<span id="cb1-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">makepkg</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-si</span></span></code></pre></div></div>
</section>
<section id="instalar-rstudio-usando-yay" class="level2">
<h2 class="anchored" data-anchor-id="instalar-rstudio-usando-yay">Instalar RStudio usando <em>yay</em></h2>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">yay</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-S</span> rstudio-desktop-bin</span></code></pre></div></div>
</section>
<section id="instalación-de-openblas" class="level2">
<h2 class="anchored" data-anchor-id="instalación-de-openblas">Instalación de OpenBLAS</h2>
<p>Las librerías de BLAS instaladas por defecto en Manjaro no son las de mejor rendimiento. Para incrementar el rendimiento, se recomienda instalar <a href="http://www.openblas.net/"><em>OpenBLAS</em></a>, el cual ofrece la posibilidad de usar múltiples núcleos del CPU en vez de uno solo, como normalmente ocurre. Para instalar OpenBLAS:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">yay</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-S</span> openblas-lapack</span></code></pre></div></div>
<p>Durante el proceso de instalación tendrás que remover los paquetes antiguos. Luego de culminada la instalación no es necesario configurar nada. R estará usando los CPU disponibles.</p>
</section>
<section id="una-última-recomendación" class="level2">
<h2 class="anchored" data-anchor-id="una-última-recomendación">Una última recomendación</h2>
<p>Muchos paquetes de R requerirán un compilador de Fortran. Luego de la instalación es recomendable instalar gcc-fortran:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sudo</span> pacman <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-S</span> gcc-fortran</span></code></pre></div></div>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Nota
</div>
</div>
<div class="callout-body-container callout-body">
<p>Si usas Windows, puedes instalar RStudio siguiendo este <a href="https://www.youtube.com/watch?v=IyJuTU82ikM">tutorial</a>.</p>
</div>
</div>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Cómo citar</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{saturno2019,
  author = {Saturno, Jorge},
  title = {RStudio en Manjaro Linux},
  date = {2019-04-05},
  url = {https://kumulonimb.us/apuntes/RStudio/},
  doi = {10.59350/bj4w8-v7f39},
  langid = {es}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cita este trabajo como:</div><div id="ref-saturno2019" class="csl-entry quarto-appendix-citeas">
Saturno, Jorge. 2019. <span>“RStudio en Manjaro Linux.”</span> April 5.
<a href="https://doi.org/10.59350/bj4w8-v7f39">https://doi.org/10.59350/bj4w8-v7f39</a>.
</div></div></section></div> ]]></description>
  <category>r</category>
  <category>rstudio</category>
  <category>manjaro</category>
  <guid>https://kumulonimb.us/apuntes/RStudio/</guid>
  <pubDate>Thu, 04 Apr 2019 22:00:00 GMT</pubDate>
  <media:content url="https://kumulonimb.us/apuntes/RStudio/img/featured.webp" medium="image" type="image/webp"/>
</item>
<item>
  <title>Publicar sitio web usando Hugo</title>
  <dc:creator>Jorge Saturno</dc:creator>
  <link>https://kumulonimb.us/apuntes/Hugo-blog/</link>
  <description><![CDATA[ 





<p>Esta entrada es un tutorial para crear un sitio web personal con CV y blog usando el tema <a href="https://sourcethemes.com/academic/"><strong>Academic</strong></a> para <em>Hugo</em>. Existen muchas alternativas para crear un blog. Quizás las más conocidas sean <em>wordpress</em> y <em>blogspot</em>. Recientemente, mucha gente está optando por <em>medium</em> para bloguear. Aunque <em>medium</em> podría ofrecer la posibilidad de llegar a una audiencia más amplia, tiene grandes desventajas, ya que es una plataforma cerrada e inflexible. :thumbsdown:</p>
<p>Usualmente los blogs son sitios dinámicos (un servidor consulta una base de datos y produce el contenido dependiendo de lo que el usuarie quiera leer). Con <a href="https://picodotdev.github.io/blog-bitix/2018/05/generador-de-paginas-web-estaticas-y-bitacoras-con-hugo/"><em>Hugo</em></a> podemos crear un sitio web completamente estático (sin bases de datos) y usarlo como blog. ¿Las ventajas? Es mucho más ligero y no necesitas pagar un costoso hospedaje o tener un sitio web gratuito lleno de publicidad. De hecho, con <em>Hugo</em> puedes crear un sitio web profesional y atractivo y alojarlo gratuitamente en <em>GitHub</em> o <em>GitLab</em>. Sólo tendrías que pagar si quisieras tener un dominio personalizado pero no es necesario. Otra de las ventajas de <em>Hugo</em> es que no requiere que aprendas a programar. <em>Hugo</em> ofrece la posibilidad de crear tu sitio web usando el lenguaje go, a partir de archivos de texto (con formato markdown) que son muy fáciles de crear y editar.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Nota
</div>
</div>
<div class="callout-body-container callout-body">
<p>No soy programador de carrera y puede que algunos de los términos usados en este artículo no sean los técnicamente correctos.</p>
</div>
</div>
<p>¿Qué necesitas para crear el sitio académico con <em>Hugo</em>?</p>
<ul>
<li>Una cuenta en <em>GitHub</em> o <em>GitLab</em> donde hospedarás tu sitio.</li>
<li>Instalar <em>Hugo</em> en tu computadora.</li>
<li>Programa para editar archivos de texto.</li>
<li>Lista de publicaciones académicas en un archivo <em>bibtex</em>.</li>
</ul>
<p>Ya que vamos a crear un blog académico como el que estás leyendo, usaremos el tema <strong>Academic</strong> de <em>Hugo</em> -También puedes usar otros temas que puedes encontrar en la <a href="https://themes.gohugo.io/">galería de temas de <em>Hugo</em></a>-</p>
<section id="instalar-hugo" class="level2">
<h2 class="anchored" data-anchor-id="instalar-hugo">Instalar Hugo</h2>
<p>La instalación de <em>Hugo</em> depende del sistema operativo que uses. Puedes encontrar detalles de distintas instalaciones en inglés en este <a href="https://gohugo.io/getting-started/installing/#quick-install">sitio</a> o <a href="https://blog.adrianistan.eu/2016/05/26/tutorial-hugo-espanol-generador-sitios-estaticos/">acá</a>, en español.</p>
<p>En Arch Linux o Manjaro puedes ejecutar</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sudo</span> pacman <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-Syu</span> hugo</span></code></pre></div></div>
<p>En Ubuntu o Debian,</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sudo</span> apt-get install hugo</span></code></pre></div></div>
</section>
<section id="preparar-la-plantilla-academic" class="level2">
<h2 class="anchored" data-anchor-id="preparar-la-plantilla-academic">Preparar la plantilla <strong>Academic</strong></h2>
<p>Lo primero que haremos es clonar el tema <strong>Academic</strong> y guardarlo localmente en nuestra computadora. Para ello, ejecuta los siguientes comandos:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> clone https://GitHub.com/sourcethemes/academic-kickstart.git Mi_sitio</span>
<span id="cb3-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> Mi_sitio</span>
<span id="cb3-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> submodule update <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--init</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--recursive</span></span></code></pre></div></div>
<p>Luego se debe crear un nuevo repositorio en <em>GitHub</em> o <em>GitLab</em>. En el caso de usar <em>GitHub</em>, el repositorio debería llamarse <code>&lt;usuarie&gt;.github.io</code>. Este es el repositorio donde el sitio final será alojado. Agrega este repositorio a un submódulo de la siguiente manera:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> submodule add <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-f</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-b</span> master https://github.com/<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>usuarie<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>usuarie<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>.github.io.git public</span></code></pre></div></div>
<p>Luego, sincronizamos el repositorio local con el remoto en <em>GitHub</em>:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> add .</span>
<span id="cb5-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> commit <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Primer commit"</span></span>
<span id="cb5-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> push <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-u</span> origin master</span></code></pre></div></div>
<p>El último paso sería crear el sitio web como tal, en HTML. Esta tarea se conoce como “renderizar” el sitio y lo hará <em>Hugo</em> para nosotros. Además, el sitio web creado será guardado en la carpeta <code>/public</code> y esta carpeta es la que vamos a sincronizar con el repositorio <code>&lt;usuarie&gt;.github.io</code>, de la siguiente forma:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb6-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">hugo</span></span>
<span id="cb6-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> public</span>
<span id="cb6-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> add .</span>
<span id="cb6-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> commit <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Crear sitio"</span></span>
<span id="cb6-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> push origin master</span>
<span id="cb6-6"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> ..</span></code></pre></div></div>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Importante
</div>
</div>
<div class="callout-body-container callout-body">
<p>Ten en cuenta que estos dos últimos pasos son los que necesitarás ejecutar cada vez que quieras actualizar tu sitio, por ejemplo, para agregar una nueva entrada.</p>
</div>
</div>
</section>
<section id="primeros-pasos-para-editar-el-sitio-web" class="level2">
<h2 class="anchored" data-anchor-id="primeros-pasos-para-editar-el-sitio-web">Primeros pasos para editar el sitio web</h2>
<p>Lo primero que debemos hacer es abrir el archivo <code>config.toml</code> y cambiar las variables necesarias. Por ejemplo, podemos cambiar el nombre del sitio, nuestro nombre y biografía, etc.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode toml code-with-copy"><code class="sourceCode toml"><span id="cb7-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">baseurl</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"https://&lt;usuarie&gt;.github.io"</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Usa este URL si piensas usar GitHub</span></span>
<span id="cb7-2"></span>
<span id="cb7-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Title of your site</span></span>
<span id="cb7-4"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">title</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Blog académico de Perico de los Palotes"</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Acá cambias el título de tu sitio</span></span></code></pre></div></div>
<p>Si deseas que el sitio esté en español modifica la siguiente variables:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode toml code-with-copy"><code class="sourceCode toml"><span id="cb8-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">defaultContentLanguage</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"es"</span></span></code></pre></div></div>
<p>Hay muchas otras variables que puedes cambiar en <code>config.toml</code>, por ejemplo, tus cuentas de redes sociales, o tu foto de perfil. Recomiendo que inspecciones todo el archivo y experimentes con él.</p>
<p>Una vez listos estos cambios podemos crear el sitio usando el comando <code>hugo</code>. Luego de creado el sitio, puedes visualizarlo ejecutando el comando <code>hugo server</code>. Esta es una vista preliminar. Puedes cambiar otras variables o seguir los siguientes pasos para agregar tus publicaciones y tu primera entrada al blog. Es recomendable visualizarlo localmente antes de sincronizar con <em>GitHub</em>. Para ello, abre la siguiente dirección en el navegador: <code>localhost:1313</code>.</p>
</section>
<section id="crear-lista-de-publicaciones-académicas" class="level2">
<h2 class="anchored" data-anchor-id="crear-lista-de-publicaciones-académicas">Crear lista de publicaciones académicas</h2>
<p>Necesitas tener una lista de tus publicaciones como archivo <em>bibtex</em>. Esto puedes hacerlo desde tu gestor de referencias (zotero, <a href="http://tuxtor.shekalug.org/generar-referencias-bibtex-con-mendeley/">mendeley</a>, etc.) Luego, con el archivo <em>bibtex</em>, podrás producir los archivos .md requeridos para mostrar cada publicación, los cuales se localizarán en el directorio <code>content/publication</code>. No te preocupes que este proceso se puede hacer fácilmente usando un código de python que prepararon los desarrolladores.</p>
<p>Si tienes instalado Python 3, ve al directorio de tu sitio academic y ejecuta el script de la siguiente forma:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1">pip3 install <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>U academic</span>
<span id="cb9-2">academic <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">--</span>bibtex <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>directorio<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>publicaciones.bib<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span></code></pre></div></div>
<p>Si no tienes Python instalado, <a href="https://tutorial.djangogirls.org/es/python_installation/">esta guía</a> te puede ayudar.</p>
</section>
<section id="crear-primera-entrada-en-el-blog" class="level2">
<h2 class="anchored" data-anchor-id="crear-primera-entrada-en-el-blog">Crear primera entrada en el blog</h2>
<p>Lo que tienes que hacer primero es crear un archivo “primera_entrada.md” (por sugerir un nombre) en el directorio <code>content/post</code> y editarlo.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb10-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">hugo</span> new <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--kind</span> post post/primera_entrada</span></code></pre></div></div>
<p>Abre el archivo .md en tu editor de texto y escribe algún texto usando el <a href="https://markdown.es/sintaxis-markdown/">formato markdown</a>. Una vez escrita la entrada, podemos ejecutar <code>hugo server</code> y visualizar el sitio abriendo <code>localhost:1313</code> en el navegador.</p>
<p>El último paso es cargar los archivos en el repositorio <em>GitHub</em> o <em>GitLab</em>, tal como se mostró al principio. Luego de cargados los archivos al repositorio, tu sitio web será visible en la URL “[usuarie].github.io”.</p>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Cómo citar</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{saturno2019,
  author = {Saturno, Jorge},
  title = {Publicar sitio web usando Hugo},
  date = {2019-01-05},
  url = {https://kumulonimb.us/apuntes/Hugo-blog/},
  doi = {10.59350/342cd-4cf06},
  langid = {es}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cita este trabajo como:</div><div id="ref-saturno2019" class="csl-entry quarto-appendix-citeas">
Saturno, Jorge. 2019. <span>“Publicar sitio web usando Hugo.”</span>
January 5. <a href="https://doi.org/10.59350/342cd-4cf06">https://doi.org/10.59350/342cd-4cf06</a>.
</div></div></section></div> ]]></description>
  <category>web</category>
  <category>hugo</category>
  <guid>https://kumulonimb.us/apuntes/Hugo-blog/</guid>
  <pubDate>Fri, 04 Jan 2019 23:00:00 GMT</pubDate>
  <media:content url="https://kumulonimb.us/apuntes/Hugo-blog/img/featured.webp" medium="image" type="image/webp"/>
</item>
</channel>
</rss>
