<?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>GF&#39;s blog</title>
<link>https://gustavofrosi.com.br/rss.html</link>
<atom:link href="https://gustavofrosi.com.br/rss.xml" rel="self" type="application/rss+xml"/>
<description>The blog</description>
<language>pt</language>
<generator>quarto-1.9.38</generator>
<lastBuildDate>Mon, 06 Jul 2026 03:00:00 GMT</lastBuildDate>
<item>
  <title>Do ponto à linha: criando uma regressão para além de clicar em botão</title>
  <dc:creator>Gustavo Frosi</dc:creator>
  <link>https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/</link>
  <description><![CDATA[ 






<section id="por-que-do-ponto-a-linha" class="level1">
<h1>Por que do ponto a linha?</h1>
<p>Entender a regressão aos “pedaços” funciona, mas há limites. Aqui, reúno algumas “peças” de como a regressão linear funciona. Assim, um entendimento um pouco mais amplo dos cálculos que dão origem à regressão linear é exposto. A ideia é ir do plot dos pontos até as linhas de regressão e de intervalos de confiança. Isso pode servir como base para entender não só o funcionamento como também os usos e as limitações.</p>
<p>A intenção é apenas uma: entender de onde “surgem” as “coisas” em uma regressão linear simples. O aprofundamento foi até o limite do que meu conhecimento permitiu. E, como não sou matemático nem parente próximo, por enquanto assuntos mais complexos e fundamentais do cálculo e da álgebra ficarão de lado.</p>
</section>
<section id="a-regressão-linear" class="level1">
<h1>A regressão linear</h1>
<p>A regressão linear é utilizada para quantificar e inferir a relação entre uma variável dependente e uma ou mais variáveis independentes. O princípio básico da regressão pode ser representado por:</p>
<p><span id="eq-funcao"><img src="https://latex.codecogs.com/png.latex?%0Ay%20=%20f(x)%0A%5Ctag%7B1%7D"></span></p>
<p>Basicamente, o que se busca na regressão é encontrar uma reta em que o valor dos resíduos seja o menor possível. A função que descreve isso é dada como:</p>
<p><span id="eq-emq"><img src="https://latex.codecogs.com/png.latex?%0A%5Cmin_%7B%5Cbeta_0,%5Cbeta_1%7D%20%5Csum_%7Bi=1%7D%5E%7Bn%7D%20(y_i-(%5Cbeta_0-%5Cbeta_1x_i))%5E2%0A%5Ctag%7B2%7D"></span></p>
<p>Onde os termos <img src="https://latex.codecogs.com/png.latex?%5Cmin_%7B%5Cbeta_0,%5Cbeta_1%7D"> dizem respeito a encontrar valores de <img src="https://latex.codecogs.com/png.latex?%5Cbeta"> que minimizem a função; por minimizar entende-se retornar o menor valor da função. Já <img src="https://latex.codecogs.com/png.latex?%5Csum_%7Bi=1%7D%5E%7Bn%7D"> é basicamente somar o resultado de cada operação dos <img src="https://latex.codecogs.com/png.latex?()">. E, dentro dos <img src="https://latex.codecogs.com/png.latex?()">, temos a operação que é o valor observado dado por <img src="https://latex.codecogs.com/png.latex?y_i"> menos o <img src="https://latex.codecogs.com/png.latex?y"> estimado pelos <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0;~%5Cbeta_1x_i">. Eleva-se ao quadrado para trabalhar com os valores negativos e por questões mais aprofundadas de derivada.</p>
<p>Ao fim, queremos os valores de <img src="https://latex.codecogs.com/png.latex?%5Cbeta"> que levem à menor diferença entre o <img src="https://latex.codecogs.com/png.latex?y"> estimado e o <img src="https://latex.codecogs.com/png.latex?y"> observado.</p>
<!-- Ou seja, uma função que a partir de $x$ eu obtenha os valores de $y$. Essa notação por si só já é interessante. Como posso manipular $x$ de tal forma que eu encontre $y$? Isso é fantástico. O ponto importante é que essa função precisa existir e, para além disso, eu preciso ser capaz de encontrá-la e "validá-la". -->
<div id="wrn-exp" class="callout callout-style-default callout-note callout-titled" title="Finalidade da regressão">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-1-contents" aria-controls="callout-1" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Nota&nbsp;1: Finalidade da regressão
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-1" class="callout-1-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>Um ponto muito importante aqui é dizer que a regressão pode ser utilizada para: descrever, explicar ou predizer dados. E isso é apenas uma questão de narrativa ou objetivo da análise, dependendo puramente de quem a interpreta ou publica (<span class="citation" data-cites="kasza">Kasza e Wolfe (2014)</span>, <span class="citation" data-cites="shmueli">Shmueli (2010)</span>, <span class="citation" data-cites="altay">Altay L. Souza (2025)</span>).</p>
</div>
</div>
</div>
<p>O modelo matemático da regressão linear pode ser expresso como:</p>
<p><span id="eq-regline"><img src="https://latex.codecogs.com/png.latex?%0Ay%20=%20%5Cbeta_%7B0%7D%20+%20%5Cbeta_%7B1%7D%20x%20+%20%5Cepsilon%0A%5Ctag%7B3%7D"></span></p>
<p>Além disso, é importante que os erros possuam uma distribuição normal com média zero e variância constante.</p>
<p><span id="eq-erros"><img src="https://latex.codecogs.com/png.latex?%0A%5Cepsilon%20%5Csim%20N(0,%5Csigma%5E2)%0A%5Ctag%7B4%7D"></span></p>
<p>No entanto, o modelo acima parte do pressuposto de que vamos encontrar os verdadeiros e pontuais valores para os <img src="https://latex.codecogs.com/png.latex?%5Cbeta">s, o que não é necessariamente verdade. Na realidade, o que realizamos na maior parte dos casos é encontrar os valores dos <img src="https://latex.codecogs.com/png.latex?%5Cbeta">s de uma amostra que, em teoria, deve ser uma representação da população (faça uma boa amostragem!). Com isso, o que encontramos na análise são valores médios para os <img src="https://latex.codecogs.com/png.latex?%5Cbeta">s que, dentro de intervalos de confiança, são encontrados como os verdadeiros valores na população. Sendo assim, a equação que utilizamos deve ser:</p>
<p><span id="eq-regestimada"><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7By%7D%20=%20%5Chat%7B%5Cbeta_%7B0%7D%7D%20+%20%5Chat%7B%5Cbeta_%7B1%7D%7Dx%20+%20%5Cepsilon%0A%5Ctag%7B5%7D"></span></p>
<p>Uma definição mais simples é realizada na seção abaixo.</p>
<section id="nomenclaturas" class="level2">
<h2 class="anchored" data-anchor-id="nomenclaturas">Nomenclaturas</h2>
<p>É importante definir alguns símbolos que denotam um significado distinto às variáveis, às estimativas dessas e ao modelo de regressão.</p>
<ul>
<li><p>O <img src="https://latex.codecogs.com/png.latex?y"> é a variável dependente ou resposta;</p></li>
<li><p>O <img src="https://latex.codecogs.com/png.latex?%5Chat%7By%7D"> é o valor da estimativa/predição;</p></li>
<li><p>O <img src="https://latex.codecogs.com/png.latex?y_%7Bi%7D"> indica o valor observado da observação <img src="https://latex.codecogs.com/png.latex?i">, onde <img src="https://latex.codecogs.com/png.latex?i"> assume valores diferentes para cada observação do conjunto de dados;</p></li>
<li><p>O <img src="https://latex.codecogs.com/png.latex?%5Cbar%7By%7D"> é a média dos valores de <img src="https://latex.codecogs.com/png.latex?y"> da amostra;</p></li>
<li><p>O <img src="https://latex.codecogs.com/png.latex?x"> é a variável independente ou explicativa/preditora. Podemos ter mais de um <img src="https://latex.codecogs.com/png.latex?x"> e poderíamos denotá-los como: <img src="https://latex.codecogs.com/png.latex?x_%7B1%7D,%20x_%7B2%7D,%20...,%20x_%7Bn%7D">. Como a ideia é focar na regressão simples, apenas um <img src="https://latex.codecogs.com/png.latex?x"> será usado;</p></li>
<li><p>O <img src="https://latex.codecogs.com/png.latex?x_%7Bi%7D"> indica o valor de <img src="https://latex.codecogs.com/png.latex?x"> da observação <img src="https://latex.codecogs.com/png.latex?i">, onde <img src="https://latex.codecogs.com/png.latex?i"> assume valores diferentes para cada observação do conjunto de dados;</p></li>
<li><p>O <img src="https://latex.codecogs.com/png.latex?%5Cbar%7Bx%7D"> é a média dos valores de <img src="https://latex.codecogs.com/png.latex?x"> da amostra;</p></li>
<li><p><img src="https://latex.codecogs.com/png.latex?f(x)"> é o modelo, ou seja, a função de <img src="https://latex.codecogs.com/png.latex?x">;</p></li>
<li><p><img src="https://latex.codecogs.com/png.latex?%5Cepsilon"> é o erro do modelo (diferença entre o <img src="https://latex.codecogs.com/png.latex?y"> previsto e o observado);</p></li>
<li><p><img src="https://latex.codecogs.com/png.latex?%5Cepsilon_%7Bi%7D"> é o erro para cada observação;</p></li>
<li><p><img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B0%7D"> é o intercepto do modelo (ponto em <img src="https://latex.codecogs.com/png.latex?y"> onde a reta passa quando <img src="https://latex.codecogs.com/png.latex?x"> assume valor <img src="https://latex.codecogs.com/png.latex?0">). Caso a relação do modelo exista na realidade, o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B0%7D"> é o valor real da população;</p></li>
<li><p><img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_%7B0%7D%7D"> é o intercepto estimado da amostra;</p></li>
<li><p><img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B1%7D"> é o coeficiente angular do modelo (variação em <img src="https://latex.codecogs.com/png.latex?y"> com o aumento de uma unidade em <img src="https://latex.codecogs.com/png.latex?x">). Caso a relação do modelo exista na realidade, o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B1%7D"> é o valor real da população;</p></li>
<li><p><img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_%7B1%7D%7D"> é o coeficiente angular estimado da amostra;</p></li>
</ul>
</section>
</section>
<section id="desenvolvendo-a-regressão-linear" class="level1">
<h1>Desenvolvendo a regressão linear</h1>
<section id="dados-e-a-pergunta" class="level2">
<h2 class="anchored" data-anchor-id="dados-e-a-pergunta">Dados e a pergunta</h2>
<p>Para desvendar os mistérios dessa tal regressão linear simples, vamos utilizar os dados de exemplo da Tabela&nbsp;1. São apenas 6 linhas de dados, o que é bem pouco; porém, a ideia central é desenvolver a conta e, para facilitar isso, faz-se necessário um exemplo com poucos dados. Nesses dados, imaginamos que temos como variável <img src="https://latex.codecogs.com/png.latex?x"> a idade de diferentes pessoas e em <img src="https://latex.codecogs.com/png.latex?y"> a altura de cada uma em cm.</p>
<div class="cell">
<div id="tbl-teste" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-teste-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Tabela&nbsp;1: Dados para a regressão
</figcaption>
<div aria-describedby="tbl-teste-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<div id="inrgqbnsnr" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#inrgqbnsnr table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#inrgqbnsnr thead, #inrgqbnsnr tbody, #inrgqbnsnr tfoot, #inrgqbnsnr tr, #inrgqbnsnr td, #inrgqbnsnr th {
  border-style: none;
}

#inrgqbnsnr p {
  margin: 0;
  padding: 0;
}

#inrgqbnsnr .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#inrgqbnsnr .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#inrgqbnsnr .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#inrgqbnsnr .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#inrgqbnsnr .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#inrgqbnsnr .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#inrgqbnsnr .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#inrgqbnsnr .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#inrgqbnsnr .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#inrgqbnsnr .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#inrgqbnsnr .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#inrgqbnsnr .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#inrgqbnsnr .gt_spanner_row {
  border-bottom-style: hidden;
}

#inrgqbnsnr .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#inrgqbnsnr .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#inrgqbnsnr .gt_from_md > :first-child {
  margin-top: 0;
}

#inrgqbnsnr .gt_from_md > :last-child {
  margin-bottom: 0;
}

#inrgqbnsnr .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#inrgqbnsnr .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#inrgqbnsnr .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#inrgqbnsnr .gt_row_group_first td {
  border-top-width: 2px;
}

#inrgqbnsnr .gt_row_group_first th {
  border-top-width: 2px;
}

#inrgqbnsnr .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#inrgqbnsnr .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#inrgqbnsnr .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#inrgqbnsnr .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#inrgqbnsnr .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#inrgqbnsnr .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#inrgqbnsnr .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#inrgqbnsnr .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#inrgqbnsnr .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#inrgqbnsnr .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#inrgqbnsnr .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#inrgqbnsnr .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#inrgqbnsnr .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#inrgqbnsnr .gt_left {
  text-align: left;
}

#inrgqbnsnr .gt_center {
  text-align: center;
}

#inrgqbnsnr .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#inrgqbnsnr .gt_font_normal {
  font-weight: normal;
}

#inrgqbnsnr .gt_font_bold {
  font-weight: bold;
}

#inrgqbnsnr .gt_font_italic {
  font-style: italic;
}

#inrgqbnsnr .gt_super {
  font-size: 65%;
}

#inrgqbnsnr .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#inrgqbnsnr .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#inrgqbnsnr .gt_indent_1 {
  text-indent: 5px;
}

#inrgqbnsnr .gt_indent_2 {
  text-indent: 10px;
}

#inrgqbnsnr .gt_indent_3 {
  text-indent: 15px;
}

#inrgqbnsnr .gt_indent_4 {
  text-indent: 20px;
}

#inrgqbnsnr .gt_indent_5 {
  text-indent: 25px;
}

#inrgqbnsnr .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#inrgqbnsnr div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table cell caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="gt_heading header">
<td colspan="2" class="gt_heading gt_title gt_font_normal gt_bottom_border">Dados de exemplo</td>
</tr>
<tr class="gt_col_headings even">
<th id="x" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col">x - Idade (anos)<br>
(Variável independente)</th>
<th id="y" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col">y - Altura (cm)<br>
(Variável dependente)</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_center" headers="x">5</td>
<td class="gt_row gt_center" headers="y">110</td>
</tr>
<tr class="even">
<td class="gt_row gt_center" headers="x">7</td>
<td class="gt_row gt_center" headers="y">120</td>
</tr>
<tr class="odd">
<td class="gt_row gt_center" headers="x">9</td>
<td class="gt_row gt_center" headers="y">120</td>
</tr>
<tr class="even">
<td class="gt_row gt_center" headers="x">11</td>
<td class="gt_row gt_center" headers="y">135</td>
</tr>
<tr class="odd">
<td class="gt_row gt_center" headers="x">13</td>
<td class="gt_row gt_center" headers="y">155</td>
</tr>
<tr class="even">
<td class="gt_row gt_center" headers="x">15</td>
<td class="gt_row gt_center" headers="y">168</td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
</figure>
</div>
</div>
<p>O primeiro passo é se perguntar: <strong>A idade das pessoas tem efeito na altura?</strong></p>
<p>Essa pergunta, para ser respondida por meio da regressão, deve ser expressa em termos da equação como: <span id="eq-regdados"><img src="https://latex.codecogs.com/png.latex?%0AAltura%20=%20%5Cbeta_%7B0%7D%20+%20%5Cbeta_%7B1%7D%20Idade%20+%20%5Cepsilon%0A%5Ctag%7B6%7D"></span></p>
<div id="wrn-exp" class="callout callout-style-default callout-note callout-titled" title="Para experimentos">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-2-contents" aria-controls="callout-2" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Nota&nbsp;2: Para experimentos
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-2" class="callout-2-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>Vale lembrar que em um experimento a pergunta é feita antes da análise e que o delineamento do experimento vai refletir a análise a ser utilizada.</p>
</div>
</div>
</div>
<p>Como temos apenas uma variável <img src="https://latex.codecogs.com/png.latex?x">, podemos criar um gráfico traçando a interseção entre o eixo das abscissas ou <img src="https://latex.codecogs.com/png.latex?x"> e o eixo das ordenadas ou <img src="https://latex.codecogs.com/png.latex?y"> <img src="https://latex.codecogs.com/png.latex?(x;y)"> (Figura&nbsp;1) e verificar como os dados estão dispersos.</p>
<div id="fig-dispersao" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-dispersao-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="disper.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-1" title="Figura&nbsp;1: Gráfico de dispersão dos dados"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/disper.jpeg" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-dispersao-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;1: Gráfico de dispersão dos dados
</figcaption>
</figure>
</div>
<p>O que podemos analisar é que parece existir uma relação entre a idade e a altura. Parece que as pessoas mais velhas também são mais altas, pelo menos nessa amostra. Esse é um primeiro indício de que podemos fazer uma regressão com esses dados.</p>
</section>
<section id="estimando-os-betas" class="level2">
<h2 class="anchored" data-anchor-id="estimando-os-betas">Estimando os <img src="https://latex.codecogs.com/png.latex?%5Cbeta">s</h2>
<p>Para estimar o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> utilizamos a Equação&nbsp;7:</p>
<p><span id="eq-beta1"><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cbeta_%7B1%7D%7D%20=%20%5Cfrac%7B%5Csum(x_%7Bi%7D-%5Cbar%7Bx%7D)(y_%7Bi%7D-%5Cbar%7By%7D)%7D%7B%5Csum(x_%7Bi%7D-%5Cbar%7Bx%7D)%5E2%7D%0A%5Ctag%7B7%7D"></span></p>
<p>Aqui, observamos que no numerador temos o somatório do produto entre os desvios de <img src="https://latex.codecogs.com/png.latex?x"> e de <img src="https://latex.codecogs.com/png.latex?y">. A ideia é verificar o quanto os valores observados estão distantes da média, para cada eixo, e depois multiplicar essas distâncias para observar se a relação é positiva ou negativa. Assim, obtém-se se a relação é de crescimento ou de decrescimento. Ao fim, soma-se tudo, pois o objetivo é usar todos os dados para obter uma única reta. Já no denominador temos os desvios de <img src="https://latex.codecogs.com/png.latex?x"> ao quadrado, o que serve para verificar o quanto <img src="https://latex.codecogs.com/png.latex?x"> varia de forma isolada. A divisão é como se tivéssemos o quanto <img src="https://latex.codecogs.com/png.latex?x"> e <img src="https://latex.codecogs.com/png.latex?y"> variam juntos dividido pelo quanto <img src="https://latex.codecogs.com/png.latex?x"> varia sozinho. Ao fim, o resultado é o quanto <img src="https://latex.codecogs.com/png.latex?y"> muda para cada unidade de mudança em <img src="https://latex.codecogs.com/png.latex?x">.</p>
<p>Já para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> é muito mais simples: basta isolá-lo e substituir o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> encontrado pela Equação&nbsp;7 em Equação&nbsp;8:</p>
<p><span id="eq-beta0"><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cbeta_%7B0%7D%7D%20=%20%5Cbar%7By%7D%20-%20%5Chat%7B%5Cbeta_%7B1%7D%7D%20%20%5Cbar%7Bx%7D%0A%5Ctag%7B8%7D"></span></p>
<p>Mas também podemos encontrar o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> por meio da Equação&nbsp;9.</p>
<p><span id="eq-beta02"><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cbeta%7D_0%20=%0A%5Cfrac%7B%0A%5Csum%20y_i%20%5Csum%20x_i%5E2%20-%0A%5Csum%20x_i%20%5Csum%20x_i%20y_i%0A%7D%7B%0An%20%5Csum%20x_i%5E2%20-%0A(%5Csum%20x_i)%5E2%0A%7D%0A%5Ctag%7B9%7D"></span></p>
<p>No numerador temos o somatório dos valores observados de <img src="https://latex.codecogs.com/png.latex?y"> (<img src="https://latex.codecogs.com/png.latex?%5Csum%20y_i">) multiplicado pelo somatório do quadrado dos valores observados de <img src="https://latex.codecogs.com/png.latex?x"> (<img src="https://latex.codecogs.com/png.latex?%5Csum%20x_i%5E2">), tudo isso menos o somatório dos valores observados de <img src="https://latex.codecogs.com/png.latex?x"> (<img src="https://latex.codecogs.com/png.latex?%5Csum%20x_i">) multiplicado pela soma dos produtos de <img src="https://latex.codecogs.com/png.latex?x"> e <img src="https://latex.codecogs.com/png.latex?y"> (<img src="https://latex.codecogs.com/png.latex?%5Csum%20x_i%20y_i">). Já no denominador temos o número de observações (<img src="https://latex.codecogs.com/png.latex?n">) multiplicado pelo somatório das observações de <img src="https://latex.codecogs.com/png.latex?x"> ao quadrado (<img src="https://latex.codecogs.com/png.latex?%5Csum%20x_i%5E2">) menos o quadrado da soma de <img src="https://latex.codecogs.com/png.latex?x"> (<img src="https://latex.codecogs.com/png.latex?(%5Csum%20x_i)%5E2">). A ideia aqui é explicar quanto da altura da reta não se deve à inclinação (<img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_1%7D">).</p>
</section>
<section id="estimando-os-betas-do-problema" class="level2">
<h2 class="anchored" data-anchor-id="estimando-os-betas-do-problema">Estimando os betas do problema</h2>
<p>A ideia é encontrar quais os melhores valores para <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_%7B0%7D%7D"> e para <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_%7B1%7D%7D"> com o menor erro possível. Para isso será utilizada a Equação&nbsp;7 e a Equação&nbsp;8.</p>
<p>Primeiro, calcula-se a média de <img src="https://latex.codecogs.com/png.latex?x"> e de <img src="https://latex.codecogs.com/png.latex?y">:</p>
<div class="columns">
<div class="column" style="width:20%;">
<p><img src="https://latex.codecogs.com/png.latex?%5Cbar%7Bx%7D%20=%20%5Cfrac%7B%5Csum%20x_i%7D%7Bn%7D"></p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbar%7By%7D%20=%20%5Cfrac%7B%5Csum%20y_i%7D%7Bn%7D"></p>
</div><div class="column" style="width:80%;">
<p><span id="eq-mediax"><img src="https://latex.codecogs.com/png.latex?%0A%5Cbar%7Bx%7D%20=%20%5Cfrac%7B5+7+9+11+13+15%7D%7B6%7D%20=%2010%0A%5Ctag%7B10%7D"></span></p>
<p><span id="eq-mediay"><img src="https://latex.codecogs.com/png.latex?%0A%5Cbar%7By%7D%20=%20%5Cfrac%7B110+120+120+135+155+168%7D%7B6%7D%20=%20134.67%0A%5Ctag%7B11%7D"></span></p>
</div>
</div>
<p>Depois, iniciamos o cálculo do <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_1%7D">, e o primeiro passo é fazer a soma do produto dos desvios de cada observação em relação à média de <img src="https://latex.codecogs.com/png.latex?x"> e de <img src="https://latex.codecogs.com/png.latex?y">. Graficamente podemos observar o que está sendo realizado, conforme a Figura&nbsp;2.</p>
<div id="fig-mediamedia" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-mediamedia-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="media_media_desvi.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-2" title="Figura&nbsp;2: A) Dispersão dos dados e linhas de médias; B) Adição de linhas de desvios."><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/media_media_desvi.jpeg" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-mediamedia-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;2: A) Dispersão dos dados e linhas de médias; B) Adição de linhas de desvios.
</figcaption>
</figure>
</div>
<p>O numerador para o <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_1%7D"> tem o valor de <img src="https://latex.codecogs.com/png.latex?410"> e foi encontrado da seguinte forma:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5Csum(x_%7Bi%7D-%5Cbar%7Bx%7D)(y_%7Bi%7D-%5Cbar%7By%7D)%20=%5C;&amp;%0A(5-10)*(110-134.67)%20+%20(7-10)*(120-134.67)%20+%20%7B%7D%20%5C%5C%0A&amp;%0A(9-10)*(120-134.67)%20+%20(11-10)*(135-134.67)%20+%20%7B%7D%20%5C%5C%0A&amp;%0A(13-10)*(155-134.67)%20+%20(15-10)*(168-134.67)%0A%5Cend%7Baligned%7D%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Csum(x_%7Bi%7D-%5Cbar%7Bx%7D)(y_%7Bi%7D-%5Cbar%7By%7D)%20=%20123.33+44+16.67+0.33+61+166.67=%20410%0A"></p>
<p>Já para o denominador temos um valor de <img src="https://latex.codecogs.com/png.latex?70">, encontrado com base no seguinte cálculo:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5Csum(x_i%20-%20%5Cbar%7Bx%7D)%5E2%20=%20%5C;&amp;%20(5%20-%2010)%5E2%20+%20(7-10)%5E2%20+%20(9-10)%5E2%20+%20%7B%7D%20%5C%5C%0A&amp;%0A(11-10)%5E2%20+%20(13-10)%5E2%20+%20(15-10)%5E2%0A%5Cend%7Baligned%7D%0A"></p>
<p><span id="eq-somadesviox"><img src="https://latex.codecogs.com/png.latex?%0A%5Csum(x_i%20-%20%5Cbar%7Bx%7D)%5E2%20=%2025+9+1+1+9+25%20=%2070%0A%5Ctag%7B12%7D"></span></p>
<p>Agora, para encontrar o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1">, basta fazer a divisão, que resulta em 5.86.</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_1%7D%20=%20%5Cfrac%7B410%7D%7B70%7D%20=%205.86"></p>
<p>Para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> é só fazer a substituição na equação de regressão (Equação&nbsp;8) e obtemos o valor de 76.10.</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cbeta_%7B0%7D%7D%20=%20134.67%20-%205.86%20*%2010%20=%2076.10%0A"></p>
</section>
<section id="modelo-final" class="level2">
<h2 class="anchored" data-anchor-id="modelo-final">Modelo final</h2>
<p>Agora podemos descrever a equação completa (Equação&nbsp;3) como:</p>
<p><span id="eq-regfinal"><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7By%7D%20=%2076.10%20+%205.86x%0A%5Ctag%7B13%7D"></span></p>
<p>E, graficamente, como na Figura&nbsp;3, onde observamos o modelo e a equação que descreve a relação entre idade e altura para esses dados simulados. Um outro detalhe importante é que a regressão linear pelo método dos mínimos quadrados obrigatoriamente passará pela média de <img src="https://latex.codecogs.com/png.latex?x"> e de <img src="https://latex.codecogs.com/png.latex?y">, o que também observamos na Figura&nbsp;3 no cruzamento das linhas tracejadas.</p>
<div id="fig-dispreg" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-dispreg-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="disper_reg.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-3" title="Figura&nbsp;3: Modelo de regressão para o problema do exemplo"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/disper_reg.jpeg" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-dispreg-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;3: Modelo de regressão para o problema do exemplo
</figcaption>
</figure>
</div>
<p>Ainda nos falta calcular se o modelo serve para algo, o <img src="https://latex.codecogs.com/png.latex?R%5E2">, os intervalos de confiança dos coeficientes e a significância dos betas, além de interpretar o modelo.</p>
<div id="wrn-exp" class="callout callout-style-default callout-note callout-titled" title="Pressupostos">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-3-contents" aria-controls="callout-3" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Nota&nbsp;3: Pressupostos
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-3" class="callout-3-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>A análise de regressão possui pressupostos fortes que não devem ser ignorados. Por uma questão de objetivo, não realizarei a análise dos resíduos ou a verificação dos pressupostos.</p>
</div>
</div>
</div>
</section>
<section id="análise-de-variância-da-regressão" class="level2">
<h2 class="anchored" data-anchor-id="análise-de-variância-da-regressão">Análise de variância da regressão</h2>
<p>Uma forma muito interessante de verificar se o modelo é útil é por meio da análise das variâncias. Interprete “útil” como um modelo que consegue explicar parte da variabilidade dos dados de forma superior a um modelo nulo, que utiliza apenas a média.</p>
<p>Para chegar a isso, podemos descrever a diferença entre os valores observados e a média como: a diferença entre o valor estimado e a média mais a diferença entre o valor observado e o estimado (Equação&nbsp;14).</p>
<p><span id="eq-desvios"><img src="https://latex.codecogs.com/png.latex?%0Ay_i%20-%20%5Cbar%7By%7D%0A=%0A(%5Chat%7By%7D_i%20-%20%5Cbar%7By%7D)%0A+%0A(y_i%20-%20%5Chat%7By%7D_i)%0A%5Ctag%7B14%7D"></span></p>
<p>Em outras palavras, o primeiro componente após a igualdade na equação se refere ao modelo e ao quanto suas estimativas estão distantes do valor médio. Já a segunda parte diz respeito ao erro ou resíduo, que é o quanto da explicação não foi capturado pelo modelo (Figura&nbsp;4).</p>
<div id="fig-errosdomodelo" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-errosdomodelo-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="desvios_mod_erro.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-4" title="Figura&nbsp;4: "><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/desvios_mod_erro.jpeg" id="fig-errosdomodelo" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-errosdomodelo-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;4
</figcaption>
</figure>
</div>
<p>Podemos elevar tudo ao quadrado e somar, obtendo assim a soma de quadrados. Essa também pode ser particionada, conforme a Equação&nbsp;15. Assim teremos a soma de quadrados total <img src="https://latex.codecogs.com/png.latex?(SQT%20=%20%5Csum_%7Bi=1%7D%5E%7Bn%7D(y_i%20-%20%5Cbar%7By%7D)%5E2)">, a soma de quadrados do modelo <img src="https://latex.codecogs.com/png.latex?(SQM%20=%5Csum_%7Bi=1%7D%5E%7Bn%7D(%5Chat%7By%7D_i%20-%20%5Cbar%7By%7D)%5E2)"> e a soma de quadrados do erro <img src="https://latex.codecogs.com/png.latex?(SQR=%20%5Csum_%7Bi=1%7D%5E%7Bn%7D(y_i%20-%20%5Chat%7By%7D)%5E2)">.</p>
<p><span id="eq-sqt"><img src="https://latex.codecogs.com/png.latex?%0A%5Csum_%7Bi=1%7D%5E%7Bn%7D(y_i%20-%20%5Cbar%7By%7D)%5E2=%5Csum_%7Bi=1%7D%5E%7Bn%7D(%5Chat%7By%7D_i%20-%0A%5Cbar%7By%7D)%5E2+%5Csum_%7Bi=1%7D%5E%7Bn%7D(y_i%20-%20%5Chat%7By%7D)%5E2%0A%5Ctag%7B15%7D"></span></p>
<section id="coeficiente-de-determinação-r2" class="level3">
<h3 class="anchored" data-anchor-id="coeficiente-de-determinação-r2">Coeficiente de determinação <img src="https://latex.codecogs.com/png.latex?(R%5E2)"></h3>
<p>Essa métrica é basicamente uma medida do efeito de <img src="https://latex.codecogs.com/png.latex?x"> em reduzir a variabilidade de <img src="https://latex.codecogs.com/png.latex?y">. Pode ser obtida como na Equação&nbsp;16, que é a soma de quadrados do resíduo dividida pela soma de quadrados total.</p>
<p><span id="eq-rdois"><img src="https://latex.codecogs.com/png.latex?%0AR%5E2%20=%201%20-%20%5Cfrac%7B%5Csum%20(y_i%20-%20%7B%5Ccolor%7Bblue%7D%7B%5Chat%7By%7D_i%7D%7D)%5E2%7D%0A%7B%5Csum%20(y_i%20-%20%7B%5Ccolor%7Bred%7D%7B%5Cbar%7By%7D%7D%7D)%5E2%7D%20=%201%20-%20%5Cfrac%7B%7B%5Ccolor%7Bblue%7D%7BSQR%7D%7D%7D%7B%7B%5Ccolor%7Bred%7D%7BSQT%7D%7D%7D%0A%5Ctag%7B16%7D"></span></p>
<p><a href="r2.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-5"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/r2.jpeg" class="img-fluid"></a></p>
<p>O <img src="https://latex.codecogs.com/png.latex?R%5E2"> varia entre <img src="https://latex.codecogs.com/png.latex?0"> e <img src="https://latex.codecogs.com/png.latex?1">. O valor de <img src="https://latex.codecogs.com/png.latex?0"> é encontrado quando não existe relação linear entre <img src="https://latex.codecogs.com/png.latex?x"> e <img src="https://latex.codecogs.com/png.latex?y">, ou seja, a variável <img src="https://latex.codecogs.com/png.latex?x"> não explica nada da variação de <img src="https://latex.codecogs.com/png.latex?y"> e a média de <img src="https://latex.codecogs.com/png.latex?y"> poderia ser utilizada como estimativa do valor mais provável. Já o valor de <img src="https://latex.codecogs.com/png.latex?1"> é encontrado quando <img src="https://latex.codecogs.com/png.latex?x"> explica toda a variação de <img src="https://latex.codecogs.com/png.latex?y">. Nesse caso, é possível dizer que mudanças no valor de <img src="https://latex.codecogs.com/png.latex?x"> também têm efeito no valor de <img src="https://latex.codecogs.com/png.latex?y">. Essa “força” pode ser observada na Figura&nbsp;5.</p>
<div id="fig-rdoisanima" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-rdoisanima-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="r2_reta_fixa.gif" class="lightbox" data-gallery="quarto-lightbox-gallery-6" title="Figura&nbsp;5: Simulação do coeficiente de determinação"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/r2_reta_fixa.gif" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-rdoisanima-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;5: Simulação do coeficiente de determinação
</figcaption>
</figure>
</div>
</section>
<section id="coeficiente-de-determinação-r2-do-exemplo" class="level3">
<h3 class="anchored" data-anchor-id="coeficiente-de-determinação-r2-do-exemplo">Coeficiente de determinação <img src="https://latex.codecogs.com/png.latex?(R%5E2)"> do exemplo</h3>
<p>Agora, vou aplicar as equações para determinar o coeficiente de determinação do modelo de regressão entre a idade e a altura.</p>
<p>Primeiro, para calcular o numerador é necessário substituir os valores de <img src="https://latex.codecogs.com/png.latex?x"> na equação para obter os valores de <img src="https://latex.codecogs.com/png.latex?%5Chat%7By%7D">.</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7By%7D_i=%2076.09%20+%205.86%20*%20x_i%0A"></p>
<p><span id="eq-ychapel"><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%7By%7D%7D%20=%0A%5Cbegin%7Bbmatrix%7D%0A%5Chat%7By%7D_1%20%5C%5C%0A%5Chat%7By%7D_2%20%5C%5C%0A%5Chat%7By%7D_3%20%5C%5C%0A%5Chat%7By%7D_4%20%5C%5C%0A%5Chat%7By%7D_5%20%5C%5C%0A%5Chat%7By%7D_6%0A%5Cend%7Bbmatrix%7D%0A=%0A%5Cbegin%7Bbmatrix%7D%0A105.38%20%5C%5C%0A117.10%20%5C%5C%0A128.81%20%5C%5C%0A140.52%20%5C%5C%0A152.24%20%5C%5C%0A163.95%0A%5Cend%7Bbmatrix%7D%0A%5Ctag%7B17%7D"></span></p>
<p>Agora, podemos fazer o cálculo do denominador, ou seja, a soma de quadrados do erro.</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5Csum%20(y_i%20-%20%5Chat%7By%7D_i)%5E2%0A=%20%5C;&amp;%20(110-105.38)%5E2%20+%20(120-117.10)%5E2%20+%20(120-128.81)%5E2%20%5C%5C%0A&amp;%20+%20(135-140.52)%5E2%20+%20(155-152.24)%5E2%20+%20(168-163.95)%5E2%0A%5Cend%7Baligned%7D%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Csum%20(y_i%20-%20%5Chat%7By%7D_i)%5E2=%20161.90%0A"></p>
<p>Já para o numerador é mais simples, uma vez que se utiliza a média.</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5Csum%20(y_i%20-%20%5Cbar%7By%7D)%5E2%0A=%20%5C;&amp;%20(110-134.67)%5E2%20+%20(120-134.67)%5E2%20+%20(120-134.67)%5E2%20%5C%5C%0A&amp;%20+%20(135-134.67)%5E2%20+%20(155-134.67)%5E2%20+%20(168-134.67)%5E2%0A%5Cend%7Baligned%7D%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Csum(y_i%20-%20%5Cbar%7By%7D)%5E2%20=%202563.33%0A"></p>
<p>Por fim, o <img src="https://latex.codecogs.com/png.latex?R%5E2"> é encontrado.</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AR%5E2=%201%20-%20%5Cfrac%7B161.90%7D%7B2563.33%7D%20=%200.94%0A"></p>
</section>
<section id="teste-f" class="level3">
<h3 class="anchored" data-anchor-id="teste-f">Teste <img src="https://latex.codecogs.com/png.latex?F"></h3>
<p>Outra forma de verificar a variância é por meio do teste F ou análise da variância (ANOVA). A Tabela&nbsp;2 apresenta o teste F e o p-valor para o modelo. Aqui não cabem as explicações para os cálculos da ANOVA, embora boa parte seja feita na regressão.</p>
<p>Como resultado principal temos que o p-valor é menor que 0.05, indicando que o modelo é significativo. Portanto, temos evidência de que o modelo é melhor que a média para explicar a variação de <img src="https://latex.codecogs.com/png.latex?y">.</p>
<div class="cell">
<div id="tbl-anova" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-anova-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Tabela&nbsp;2: ANOVA para a regressão linear do exemplo
</figcaption>
<div aria-describedby="tbl-anova-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<div id="thxwmqlepo" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#thxwmqlepo table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#thxwmqlepo thead, #thxwmqlepo tbody, #thxwmqlepo tfoot, #thxwmqlepo tr, #thxwmqlepo td, #thxwmqlepo th {
  border-style: none;
}

#thxwmqlepo p {
  margin: 0;
  padding: 0;
}

#thxwmqlepo .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #000000;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#thxwmqlepo .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#thxwmqlepo .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#thxwmqlepo .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#thxwmqlepo .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#thxwmqlepo .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#thxwmqlepo .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#thxwmqlepo .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#thxwmqlepo .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#thxwmqlepo .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#thxwmqlepo .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#thxwmqlepo .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#thxwmqlepo .gt_spanner_row {
  border-bottom-style: hidden;
}

#thxwmqlepo .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#thxwmqlepo .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#thxwmqlepo .gt_from_md > :first-child {
  margin-top: 0;
}

#thxwmqlepo .gt_from_md > :last-child {
  margin-bottom: 0;
}

#thxwmqlepo .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#thxwmqlepo .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#thxwmqlepo .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#thxwmqlepo .gt_row_group_first td {
  border-top-width: 2px;
}

#thxwmqlepo .gt_row_group_first th {
  border-top-width: 2px;
}

#thxwmqlepo .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#thxwmqlepo .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#thxwmqlepo .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#thxwmqlepo .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#thxwmqlepo .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#thxwmqlepo .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#thxwmqlepo .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#thxwmqlepo .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#thxwmqlepo .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#thxwmqlepo .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#thxwmqlepo .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#thxwmqlepo .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#thxwmqlepo .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#thxwmqlepo .gt_left {
  text-align: left;
}

#thxwmqlepo .gt_center {
  text-align: center;
}

#thxwmqlepo .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#thxwmqlepo .gt_font_normal {
  font-weight: normal;
}

#thxwmqlepo .gt_font_bold {
  font-weight: bold;
}

#thxwmqlepo .gt_font_italic {
  font-style: italic;
}

#thxwmqlepo .gt_super {
  font-size: 65%;
}

#thxwmqlepo .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#thxwmqlepo .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#thxwmqlepo .gt_indent_1 {
  text-indent: 5px;
}

#thxwmqlepo .gt_indent_2 {
  text-indent: 10px;
}

#thxwmqlepo .gt_indent_3 {
  text-indent: 15px;
}

#thxwmqlepo .gt_indent_4 {
  text-indent: 20px;
}

#thxwmqlepo .gt_indent_5 {
  text-indent: 25px;
}

#thxwmqlepo .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#thxwmqlepo div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table cell caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="gt_heading header">
<td colspan="5" class="gt_heading gt_title gt_font_normal gt_bottom_border">Tabela ANOVA - Teste F</td>
</tr>
<tr class="gt_col_headings even">
<th id="Fonte" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col">Fonte de variação</th>
<th id="Graus-de-liberdade" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col">Graus de liberdade<br>
(df)</th>
<th id="Soma-dos-quadrados-(SQ)" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col">Soma dos quadrados<br>
(SQ)</th>
<th id="Quadrado-médio" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col">Quadrado médio<br>
QM = SQ/df</th>
<th id="Razão-F" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col">valor de F e p-valor</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_center" headers="Fonte">Regressão (x)</td>
<td class="gt_row gt_center" headers="Graus de liberdade">1 (p-1)</td>
<td class="gt_row gt_center" headers="Soma dos quadrados (SQ)">SQT - SQR = 2401.43</td>
<td class="gt_row gt_center" headers="Quadrado médio">2401.43</td>
<td class="gt_row gt_center" headers="Razão F">59.33 (p = 0.00153)</td>
</tr>
<tr class="even">
<td class="gt_row gt_center" headers="Fonte">Resíduo</td>
<td class="gt_row gt_center" headers="Graus de liberdade">4 (n-p)</td>
<td class="gt_row gt_center" headers="Soma dos quadrados (SQ)">161.9</td>
<td class="gt_row gt_center" headers="Quadrado médio">40.48</td>
<td class="gt_row gt_center" headers="Razão F"></td>
</tr>
<tr class="odd">
<td class="gt_row gt_center" headers="Fonte">Total</td>
<td class="gt_row gt_center" headers="Graus de liberdade">5 (n-1)</td>
<td class="gt_row gt_center" headers="Soma dos quadrados (SQ)">2563.33</td>
<td class="gt_row gt_center" headers="Quadrado médio"></td>
<td class="gt_row gt_center" headers="Razão F"></td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
</figure>
</div>
</div>
</section>
</section>
<section id="significância-dos-betas-do-modelo" class="level2">
<h2 class="anchored" data-anchor-id="significância-dos-betas-do-modelo">Significância dos <img src="https://latex.codecogs.com/png.latex?%5Cbeta">s do modelo</h2>
<p>Como a variável dependente <img src="https://latex.codecogs.com/png.latex?(y)"> segue uma distribuição normal e as estimativas para <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> e <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> são obtidas por meio de uma função linear de <img src="https://latex.codecogs.com/png.latex?y">, por consequência os coeficientes do modelo também possuem uma distribuição do tipo normal. Isso pode ser observado nas Equação&nbsp;18 e Equação&nbsp;19. Isso significa que, embora tenhamos as estimativas para a melhor reta, poderíamos ter infinitas retas passando entre os dados.</p>
<div class="columns">
<div class="column">
<p><span id="eq-distbeta0"><img src="https://latex.codecogs.com/png.latex?%0A%5Cbeta_0%20%5Csim%20N(%5Cbeta_0,%20%5Csigma%5E2_%7B%5Cbeta_0%7D)%0A%5Ctag%7B18%7D"></span></p>
</div><div class="column">
<p><span id="eq-distbeta1"><img src="https://latex.codecogs.com/png.latex?%0A%5Cbeta_1%20%5Csim%20N(%5Cbeta_1,%20%5Csigma%5E2_%7B%5Cbeta_1%7D)%0A%5Ctag%7B19%7D"></span></p>
</div>
</div>
<p>É possível simular o que seria isso. Partindo dos resultados da Equação&nbsp;13, utilizo os valores de <img src="https://latex.codecogs.com/png.latex?%5Cbeta">s para simular 1 mil retas de regressão mudando apenas o erro. Sabemos que em uma regressão linear os erros devem ser normais com média zero e um desvio padrão. Com isso, adiciono erros de forma pseudoaleatória na equação: <img src="https://latex.codecogs.com/png.latex?y_%7Bi%7D%20=%2076.09%20+%205.86x_%7Bi%7D%20+%20%5Cepsilon_%7Bi%7D"> e obtenho assim novas estimativas para <img src="https://latex.codecogs.com/png.latex?y">. Agora, posso utilizar esse novo <img src="https://latex.codecogs.com/png.latex?%5Chat%7By%7D"> e realizar uma regressão com os valores de <img src="https://latex.codecogs.com/png.latex?x">, calculando assim novas estimativas de <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B0%7D"> e <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B1%7D">.</p>
<p>As animações abaixo mostram os resultados das simulações. Na imagem superior esquerda temos cada uma das 1000 linhas representando a reta de regressão calculada. Já na direita e na figura inferior da esquerda temos as distribuições de <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> e <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1">, respectivamente. A linha sólida em preto é a distribuição teórica que cada estimador deveria assumir, já as barras representam os valores calculados por meio da simulação. Observamos que, de fato, as distribuições se assemelham a uma curva tipo sino e, portanto, assume-se que são “normais”.</p>
<div class="quarto-layout-panel" data-layout-nrow="2">
<div class="quarto-layout-row">
<div class="quarto-layout-cell" style="flex-basis: 50.0%;justify-content: center;">
<p><a href="linhas_regressao.gif" class="lightbox" data-gallery="quarto-lightbox-gallery-7"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/linhas_regressao.gif" class="img-fluid"></a></p>
</div>
<div class="quarto-layout-cell" style="flex-basis: 50.0%;justify-content: center;">
<p><a href="beta0.gif" class="lightbox" data-gallery="quarto-lightbox-gallery-8"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/beta0.gif" class="img-fluid"></a></p>
</div>
</div>
<div class="quarto-layout-row">
<div class="quarto-layout-cell" style="flex-basis: 50.0%;justify-content: center;">
<p><a href="beta1.gif" class="lightbox" data-gallery="quarto-lightbox-gallery-9"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/beta1.gif" class="img-fluid"></a></p>
</div>
<div class="quarto-layout-cell" style="flex-basis: 50.0%;justify-content: center;">
<p><a href="rss.gif" class="lightbox" data-gallery="quarto-lightbox-gallery-10"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/rss.gif" class="img-fluid"></a></p>
</div>
</div>
</div>
<p>Outra importante constatação é que a soma dos resíduos ao quadrado (em inglês RSS: residual sum of squares) dividida pela variância (<img src="https://latex.codecogs.com/png.latex?%5Csigma%5E2">) dos erros assume uma distribuição do tipo chi-quadrado com graus de liberdade de <img src="https://latex.codecogs.com/png.latex?n-p">, onde <img src="https://latex.codecogs.com/png.latex?n"> é número de amostras e <img src="https://latex.codecogs.com/png.latex?p"> o número de parâmetros do modelo. Para uma regressão linear simples será sempre <img src="https://latex.codecogs.com/png.latex?n-2">, pois sempre há 2 parâmetros (intercepto e coeficiente angular). A distribuição dos resíduos ao quadrado pode ser observada na figura inferior da direita.</p>
<p>A partir do conhecimento de que os estimadores (<img src="https://latex.codecogs.com/png.latex?%5Cbeta">) possuem distribuição de probabilidade é possível realizar testes de hipóteses sobre suas estimativas. Boa parte do que torna valiosa a regressão é o teste de hipótese dos coeficientes do modelo.</p>
<section id="teste-de-significância-para-beta_0-e-beta_1" class="level3">
<h3 class="anchored" data-anchor-id="teste-de-significância-para-beta_0-e-beta_1">Teste de significância para <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> e <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"></h3>
<p>Talvez o teste de hipótese mais importante de uma regressão seja em relação ao coeficiente angular ou <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1">, que é o que responde à pergunta sobre se <img src="https://latex.codecogs.com/png.latex?x"> explica <img src="https://latex.codecogs.com/png.latex?y">. Caso <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> não seja diferente de <img src="https://latex.codecogs.com/png.latex?0">, temos uma linha reta, onde a média de <img src="https://latex.codecogs.com/png.latex?y"> é suficiente para explicar sua variação e a variável <img src="https://latex.codecogs.com/png.latex?x"> é inútil.</p>
<p>Essa hipótese pode ser testada considerando:</p>
<p><img src="https://latex.codecogs.com/png.latex?H_0%20:%20%5Cbeta_1%20=%200"></p>
<p><img src="https://latex.codecogs.com/png.latex?H_1%20:%20%5Cbeta_1%20%5Cne%20%20%200"></p>
<p>A hipótese nula <img src="https://latex.codecogs.com/png.latex?(H_0)">, ou a suposição inicial, é a de que <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> não possui valor diferente de 0; já a alternativa <img src="https://latex.codecogs.com/png.latex?(H_1)"> é a de que o valor de <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> é diferente de 0.</p>
<p>Para calcular isso, utiliza-se a estatística <img src="https://latex.codecogs.com/png.latex?t"> na forma representada pela Equação&nbsp;20. Temos a diferença entre o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> estimado e o considerado como verdadeiro, dividida pelo desvio padrão do <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1">. Assume-se que essa razão possui uma distribuição do tipo <img src="https://latex.codecogs.com/png.latex?t"> de Student, logo queremos calcular uma estatística <img src="https://latex.codecogs.com/png.latex?t">.</p>
<p><span id="eq-betat"><img src="https://latex.codecogs.com/png.latex?%0At%20=%20%5Cfrac%7B%5Chat%7B%5Cbeta_1%7D-%5Cbeta_1%7D%7BSE(%5Chat%7B%5Cbeta%7D_1)%7D%20%5Csim%20t(N-2)%0A%5Ctag%7B20%7D"></span></p>
<p>Mas utilizar a distribuição <img src="https://latex.codecogs.com/png.latex?t">, pelo menos para mim, foi algo que levou tempo até entender. Mas agora sim, na Figura&nbsp;6 é possível observar o que acontece quando se divide uma distribuição Normal por uma chi-quadrado… Justamente… uma distribuição T. Isso é representado de forma indireta na Equação&nbsp;20.</p>
<div id="fig-tnormchi" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-tnormchi-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="curva_t_da_norm_chi.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-11" title="Figura&nbsp;6: Distribuição Normal, Chi-quadrado e T"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/curva_t_da_norm_chi.jpeg" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-tnormchi-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;6: Distribuição Normal, Chi-quadrado e T
</figcaption>
</figure>
</div>
<p>O <img src="https://latex.codecogs.com/png.latex?SE(%5Chat%7B%5Cbeta%7D_1)"> é o erro padrão do <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> e pode ser escrito também como: <img src="https://latex.codecogs.com/png.latex?SE(%5Chat%7B%5Cbeta%7D_1)%20=%20%5Csqrt%7B%5Cfrac%7BEQM%7D%7B%5Csum(x_1%20-%20%5Cbar%7Bx%7D)%5E2%7D%7D">, onde <img src="https://latex.codecogs.com/png.latex?EQM"> é o erro quadrático médio. Esse foi calculado na ANOVA (Tabela&nbsp;2), mas basicamente se obtém como:</p>
<p><img src="https://latex.codecogs.com/png.latex?EQM%20=%20%5Cfrac%7BSQR%7D%7B(n-p)%7D"></p>
<p>Já para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> é um pouco mais complexo e utiliza a equação:</p>
<p><span id="eq-distbeta02"><img src="https://latex.codecogs.com/png.latex?%0At%20=%20%5Cfrac%7B%5Chat%7B%5Cbeta_0%7D-%5Cbeta_0%7D%7B%5Csqrt%7BEQM*(%5Cfrac%7B(%5Cfrac%7B1%7D%7Bn%7D)+(%5Cbar%7Bx%7D%5E2)%7D%7B%5Csum(x_1%20-%20%5Cbar%7Bx%7D)%5E2%7D)%7D%7D%20%5Csim%20t(N-2)%0A%5Ctag%7B21%7D"></span></p>
</section>
<section id="teste-de-significância-para-beta_0-e-beta_1-do-problema" class="level3">
<h3 class="anchored" data-anchor-id="teste-de-significância-para-beta_0-e-beta_1-do-problema">Teste de significância para <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> e <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> do problema</h3>
<p>Como já descrito acima, o valor encontrado de <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> do modelo foi de <img src="https://latex.codecogs.com/png.latex?76.10"> e <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> de <img src="https://latex.codecogs.com/png.latex?5.86">.</p>
<p>Primeiro para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1">: se lembrarmos, a expressão <img src="https://latex.codecogs.com/png.latex?%5Csum(x_1%20-%20%5Cbar%7Bx%7D)%5E2"> já foi calculada como denominador para encontrar o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> na Equação&nbsp;7, onde obtivemos o valor de <img src="https://latex.codecogs.com/png.latex?70">. Já o <img src="https://latex.codecogs.com/png.latex?EQM"> é dado por:</p>
<p><span id="eq-eqmbeta1"><img src="https://latex.codecogs.com/png.latex?%0AEQM%20=%20%5Cfrac%7B161.90%7D%7B(6-2)%7D=40.48%0A%5Ctag%7B22%7D"></span></p>
<p>Logo:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0ASE(%5Chat%7B%5Cbeta%7D_1)%20=%20%5Csqrt%7B%5Cfrac%7B70.48%7D%7B70%7D%7D%20%20=%200.7604%0A"></p>
<p>Já para encontrar o valor da estatística <img src="https://latex.codecogs.com/png.latex?t"> para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1">, calcula-se:</p>
<p><span id="eq-tobs"><img src="https://latex.codecogs.com/png.latex?%0At%20=%20%5Cfrac%7B5.86-0%7D%7B0.7604%7D%20=%207.703%0A%5Ctag%7B23%7D"></span></p>
<p>Agora, basta verificar na distribuição <img src="https://latex.codecogs.com/png.latex?t"> qual a probabilidade de observar um valor de 7.7 ou mais extremo, e se esse valor está dentro da probabilidade de 5%, que é o nível alfa usual.</p>
<p>Na Figura&nbsp;7 é plotada a distribuição <img src="https://latex.codecogs.com/png.latex?t"> com o valor crítico de <img src="https://latex.codecogs.com/png.latex?t_c"> para um nível de significância de 5% ou 0.05. O <img src="https://latex.codecogs.com/png.latex?t_c"> diz respeito ao valor na curva <img src="https://latex.codecogs.com/png.latex?t"> que limita nosso nível de significância, ou seja, para podermos dizer que algo foi significativo a 5% nessa curva, temos que obrigatoriamente observar um valor mais extremo que <img src="https://latex.codecogs.com/png.latex?%5Cpm%202.78">.</p>
<p>Como valor de <img src="https://latex.codecogs.com/png.latex?t"> observado (<img src="https://latex.codecogs.com/png.latex?t_%7Bobs%7D">), temos o valor encontrado na Equação&nbsp;23, que foi de <img src="https://latex.codecogs.com/png.latex?7.7">, ou seja, o valor de <img src="https://latex.codecogs.com/png.latex?t_%7Bobs%7D"> é maior que o <img src="https://latex.codecogs.com/png.latex?t_c">, portanto significativo a 5% de probabilidade de erro.</p>
<p>Também podemos dizer que a probabilidade de encontrar um valor de <img src="https://latex.codecogs.com/png.latex?t"> igual ao observado é de 0.153% (<img src="https://latex.codecogs.com/png.latex?p=0.00153">), ou ainda que, dentro de todos os possíveis valores de <img src="https://latex.codecogs.com/png.latex?t"> que podemos encontrar, o observado é pouco provável.</p>
<div id="fig-disttbeta1" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-disttbeta1-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="curva_t_beta.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-12" title="Figura&nbsp;7: Distribuição t e verificação de significância estatística do coeficiente angular"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/curva_t_beta.jpeg" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-disttbeta1-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;7: Distribuição t e verificação de significância estatística do coeficiente angular
</figcaption>
</figure>
</div>
<p>Para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0">, utiliza-se a Equação&nbsp;21, mas primeiro vamos calcular o <img src="https://latex.codecogs.com/png.latex?SE(%5Chat%7B%5Cbeta%7D_0)">, conforme:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0ASE(%5Chat%7B%5Cbeta%7D_0)%20=%20%5Csqrt%7B40.48*(%5Cfrac%7B(%5Cfrac%7B1%7D%7B6%7D)+(10%5E2)%7D%7B70%7D)%7D%20=%208.035%0A"></p>
<p>Com isso, agora calculamos o <img src="https://latex.codecogs.com/png.latex?t_%7Bobs%7D"> para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0">, como:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0At%20=%20%5Cfrac%7B76.10-0%7D%7B8.035%7D%20=%209.47%0A"></p>
<p>E, da mesma forma que para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1">, podemos visualizar a distribuição e a significância estatística (Figura&nbsp;8). Também observamos um valor de <img src="https://latex.codecogs.com/png.latex?t_%7Bobs%7D"> mais extremo que o <img src="https://latex.codecogs.com/png.latex?t_c"> (<img src="https://latex.codecogs.com/png.latex?9.47%3E2.776">), portanto afirmamos que para 5% de probabilidade de erro há diferença significativa.</p>
<div id="fig-disttbeta0" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-disttbeta0-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="curva_t_beta0.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-13" title="Figura&nbsp;8: Distribuição t e verificação de significância estatística do intercepto do modelo"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/curva_t_beta0.jpeg" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-disttbeta0-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;8: Distribuição t e verificação de significância estatística do intercepto do modelo
</figcaption>
</figure>
</div>
</section>
<section id="intervalo-de-confiança-do-beta-e-da-predição-ic" class="level3">
<h3 class="anchored" data-anchor-id="intervalo-de-confiança-do-beta-e-da-predição-ic">Intervalo de confiança do beta e da predição (IC)</h3>
<p>Podemos calcular os limites onde os verdadeiros valores dos <img src="https://latex.codecogs.com/png.latex?%5Cbeta">s serão encontrados para uma determinada probabilidade: o intervalo de confiança.</p>
<p>O intervalo de confiança pode ser interpretado da seguinte forma: se o experimento fosse repetido indefinidamente, e em cada repetição fosse construído um intervalo de confiança pelo mesmo procedimento, aproximadamente 95% desses intervalos conteriam o verdadeiro valor do parâmetro. Após a coleta dos dados e a construção de um intervalo específico, não é correto afirmar que há 95% de probabilidade de o parâmetro estar dentro desse intervalo.</p>
<p>Para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> é utilizada a equação:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cbeta%7D_1%0A-%0At_%7B%5Calpha/2,%5C;n-2%7D%0A%5C,SE%5C!%5Cleft(%5Chat%7B%5Cbeta%7D_1%5Cright)%0A%5Cleq%0A%5Cbeta_1%0A%5Cleq%0A%5Chat%7B%5Cbeta%7D_1%0A+%0At_%7B%5Calpha/2,%5C;n-2%7D%0A%5C,SE%5C!%5Cleft(%5Chat%7B%5Cbeta%7D_1%5Cright)%0A"></p>
<p>Já para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> é:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cbeta%7D_0%0A-%0At_%7B%5Calpha/2,%5C;n-2%7D%0A%5C,SE%5C!%5Cleft(%5Chat%7B%5Cbeta%7D_0%5Cright)%0A%5Cleq%0A%5Cbeta_0%0A%5Cleq%0A%5Chat%7B%5Cbeta%7D_0%0A+%0At_%7B%5Calpha/2,%5C;n-2%7D%0A%5C,SE%5C!%5Cleft(%5Chat%7B%5Cbeta%7D_0%5Cright)%0A"></p>
<p>Mas, de forma resumida, o IC nada mais é que um parâmetro (nesse caso o valor de <img src="https://latex.codecogs.com/png.latex?t_c">) que multiplica uma medida de incerteza (nesse caso o erro padrão, <img src="https://latex.codecogs.com/png.latex?SE">). Assim temos que:</p>
<p><img src="https://latex.codecogs.com/png.latex?CI%20=%20t_c*%20SE(%5Chat%7B%5Cbeta%7D_1)"> e <img src="https://latex.codecogs.com/png.latex?CI%20=%20t_c*%20SE(%5Chat%7B%5Cbeta%7D_0)"></p>
<p>E para encontrar essa amplitude de IC, basta somar e subtrair do valor de <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_1%7D~ou~%5Chat%7B%5Cbeta_0%7D"></p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbeta_1~%5Cpm%7BCI%7D"> e <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0~%5Cpm%7BCI%7D"></p>
</section>
<section id="intervalo-de-confiança-do-beta-do-modelo" class="level3">
<h3 class="anchored" data-anchor-id="intervalo-de-confiança-do-beta-do-modelo">Intervalo de confiança do beta do modelo</h3>
<p>Para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> temos:</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_1%7D=%205.86"></p>
<p><img src="https://latex.codecogs.com/png.latex?SE(%5Chat%7B%5Cbeta_1%7D)=0.7604"></p>
<p><img src="https://latex.codecogs.com/png.latex?t_c%20=%207.703"></p>
<p>E o IC vai ser:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A5.86%20-%20(2.776%20*%200.7604)%20%5Cleq%20%5Cbeta_1%20%5Cleq%205.86%20+%20(2.776%20*%200.7604)%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%0A3.74913%20%5Cleq%20%5Cbeta_1%20%5Cleq%207.97087%0A"></p>
<p>Ou,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbeta_1%20=%205.86%20%5Cpm%7B2.11087%7D%0A"></p>
<p>Para o <img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"> será a mesma coisa:</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta_0%7D=%2076.1"></p>
<p><img src="https://latex.codecogs.com/png.latex?SE(%5Chat%7B%5Cbeta_0%7D)=8.035"></p>
<p><img src="https://latex.codecogs.com/png.latex?t_c%20=%209.47"></p>
<p>E o IC vai ser:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A76.1-%20(2.776%20*%208.035)%20%5Cleq%20%5Cbeta_0%20%5Cleq%2076.1%20+%20(2.776%20*%208.035)%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%0A53.79484%5Cleq%20%5Cbeta_0%20%5Cleq%2098.40516%0A"></p>
<p>Ou,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbeta_0%20=%2076.1%20%5Cpm%7B22.30516%7D%0A"></p>
</section>
<section id="intervalo-de-confiança-para-resposta-média" class="level3">
<h3 class="anchored" data-anchor-id="intervalo-de-confiança-para-resposta-média">Intervalo de confiança para resposta média</h3>
<p>Podemos também calcular “bandas” de confiança para a reta de regressão e os valores médios por todo o domínio de <img src="https://latex.codecogs.com/png.latex?x">.</p>
<p>Para isso vamos usar a Equação&nbsp;24 e o melhor… quase tudo já foi calculado. A única “entrada” agora será com valores de <img src="https://latex.codecogs.com/png.latex?x"> que podem ser novos e é dado por <img src="https://latex.codecogs.com/png.latex?x_0">, mas uso os mesmos.</p>
<p><span id="eq-icmedia"><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7By%7D(x_0)%0A%5Cpm%0At_%7B%5Calpha/2,%5C;n-2%7D%0A%5Csqrt%7B%0AEQM%0A%5Cleft(%0A%5Cfrac%7B1%7D%7Bn%7D%0A+%0A%5Cfrac%7B(x_0-%5Cbar%7Bx%7D)%5E2%7D%0A%7B%5Csum_%7Bi=1%7D%5E%7Bn%7D(x_i-%5Cbar%7Bx%7D)%5E2%7D%0A%5Cright)%0A%7D%0A%5Ctag%7B24%7D"></span></p>
</section>
<section id="intervalo-de-confiança-para-resposta-média-do-modelo" class="level3">
<h3 class="anchored" data-anchor-id="intervalo-de-confiança-para-resposta-média-do-modelo">Intervalo de confiança para resposta média do modelo</h3>
<p>Como vou utilizar os mesmos valores de <img src="https://latex.codecogs.com/png.latex?x">, os valores de <img src="https://latex.codecogs.com/png.latex?%5Chat%7By%7D"> já foram calculados em Equação&nbsp;17. Também temos os desvios de <img src="https://latex.codecogs.com/png.latex?x"> em Equação&nbsp;12, bem como o somatório, o <img src="https://latex.codecogs.com/png.latex?t"> crítico em Figura&nbsp;7 e o <img src="https://latex.codecogs.com/png.latex?EQM"> em Equação&nbsp;22. Os valores que vão mudar serão o <img src="https://latex.codecogs.com/png.latex?%5Chat%7By%7D"> e o desvio de <img src="https://latex.codecogs.com/png.latex?x"> (Equação&nbsp;25 e Equação&nbsp;26); isso é denotado na equação geral do IC com o índice <img src="https://latex.codecogs.com/png.latex?i">.</p>
<p><span id="eq-yychap"><img src="https://latex.codecogs.com/png.latex?%5Chat%7By%7D(x_0)_i%20=%20%5Cbegin%7Bbmatrix%7D%0A105.38%5C%5C%0A117.10%5C%5C%0A128.81%5C%5C%0A140.52%5C%5C%0A152.24%5C%5C%0A163.95%0A%5Cend%7Bbmatrix%7D%0A%5Ctag%7B25%7D"></span></p>
<p><span id="eq-desvioxx"><img src="https://latex.codecogs.com/png.latex?%0A(x_0-%5Cbar%7Bx%7D)%5E2_i=%20%5Cbegin%7Bbmatrix%7D%0A25%5C%5C%0A9%5C%5C%0A1%5C%5C%0A1%5C%5C%0A9%5C%5C%0A25%0A%5Cend%7Bbmatrix%7D%0A%5Ctag%7B26%7D"></span></p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0AIC_%7Binf%7D=%0A%5Chat%7By%7D(x_0)_i%0A-%0A(2.776*%0A%5Csqrt%7B%0A40.48%0A%5Cleft(%0A%5Cfrac%7B1%7D%7B6%7D%0A+%0A%5Cfrac%7B%0A(x_0-%5Cbar%7Bx%7D)%5E2_i%0A%7D%7B70%7D%0A%5Cright))%0A%7D%0A&amp;=%0A%5Cbegin%7Bbmatrix%7D%0A92.599%5C%5C%0A107.499%5C%5C%0A121.297%5C%5C%0A133.011%5C%5C%0A142.642%5C%5C%0A151.170%0A%5Cend%7Bbmatrix%7D%0A%5Cend%7Baligned%7D%0A"></p>
<p>e</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0AIC_%7Bsup%7D=%0A%5Chat%7By%7D(x_0)_i%0A+%0A(2.776*%0A%5Csqrt%7B%0A40.48%0A%5Cleft(%0A%5Cfrac%7B1%7D%7B6%7D%0A+%0A%5Cfrac%7B%0A(x_0-%5Cbar%7Bx%7D)%5E2_i%0A%7D%7B70%7D%0A%5Cright))%0A%7D%0A&amp;=%0A%5Cbegin%7Bbmatrix%7D%0A118.163%5C%5C%0A126.692%5C%5C%0A136.322%5C%5C%0A148.037%5C%5C%0A161.834%5C%5C%0A176.735%0A%5Cend%7Bbmatrix%7D%0A%5Cend%7Baligned%7D%0A"></p>
<p>Por fim, podemos plotar esses pontos e gerar as “bandas” ou a região de confiança (Figura&nbsp;9).</p>
<div id="fig-bandaconfi" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-bandaconfi-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="final.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-14" title="Figura&nbsp;9: Intervalo de confiança para a linha média do modelo"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/final.jpeg" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-bandaconfi-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;9: Intervalo de confiança para a linha média do modelo
</figcaption>
</figure>
</div>
</section>
</section>
<section id="resultado-final-da-análise" class="level2">
<h2 class="anchored" data-anchor-id="resultado-final-da-análise">Resultado final da análise</h2>
<p>Agora, podemos descrever o resultado da análise em forma de texto, o que pode ser usado para descrever qualquer regressão.</p>
<p>Exemplo de descrição de resultado:</p>
<p>Para verificar o efeito da idade (variável independente) sobre a altura (variável dependente) foi realizada uma análise de regressão linear simples. O modelo teórico é dado por: <img src="https://latex.codecogs.com/png.latex?Altura%20=%20%5Cbeta_%7B0%7D%20+%20%5Cbeta_%7B1%7D%20Idade%20+%20%5Cepsilon">.</p>
<p>O modelo é estatisticamente significativo e explica uma parte substancial da variância (<img src="https://latex.codecogs.com/png.latex?R%5E2=0.94,~F(1,4)%20=%2059.33,~p%20=%200.0015">). O efeito da idade foi significativo e positivo: a cada aumento de uma unidade na idade, a altura aumenta, em média, 5.86 cm (<img src="https://latex.codecogs.com/png.latex?CI%20%5B3.75,7.97%5D,~t(4)%20=%207.70,~p%20=%200.0015">).</p>
<p>Sobre o intercepto, temos que ter cuidado. Nosso modelo diz que, para uma pessoa com idade igual a zero, a sua altura é de 76.1 cm (<img src="https://latex.codecogs.com/png.latex?CI%5B53.79,98.41%5D,~t(4)=9.47,~p=0.0007">). A interpretação, nesse caso, deve ser baseada na área de conhecimento; neste exemplo, a menos que tenhamos um gigante, essa interpretação não faz sentido, já que, biologicamente, até onde sei, ao nascer (idade zero) as pessoas têm comprimento abaixo desse valor.</p>
<p>E isso tudo é resumido na Figura&nbsp;10.</p>
<div id="fig-finalpronto" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-finalpronto-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="disper_reg_smot.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-15" title="Figura&nbsp;10: Modelo final"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/disper_reg_smot.jpeg" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-finalpronto-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;10: Modelo final
</figcaption>
</figure>
</div>
<p>Então quer dizer que a idade ocasiona o aumento da altura? Ou seja, ficar velho te deixa alto?</p>
</section>
</section>
<section id="regressão-linear-simples-define-causa-bônus" class="level1">
<h1>Regressão linear simples define causa? (bônus)</h1>
<p>Bem, a resposta para a pergunta sobre causa é complicada. Por definição, a regressão linear <strong>não</strong> expressa causa. Em um modelo de regressão significativo, o que temos é que a variável <img src="https://latex.codecogs.com/png.latex?y"> possui associação com a variável <img src="https://latex.codecogs.com/png.latex?x">, mas não que <img src="https://latex.codecogs.com/png.latex?x"> é o responsável por causar <img src="https://latex.codecogs.com/png.latex?y">. Parece confuso, mas faz todo sentido. Isso acontece porque não temos acesso a todas as variáveis que podem estar interferindo no fenômeno e, portanto, nas observações. Dentre muitas formas de definir causa, podemos dizer que a causa possui 3 componentes: 1) direcionalidade, 2) temporalidade e 3) reprodutibilidade. Esses componentes são fundamentais para estabelecer uma relação causal, algo que a regressão linear simples não pode garantir, por si só.</p>
<p>Isso não significa que a regressão não é importante, apenas que devemos ter cuidado ao dizer que as mudanças observadas na variável dependente são <strong>causadas</strong> pela variável independente.</p>
<p>Na Figura&nbsp;11 há exemplos de algumas relações que podem ser encontradas. Como podemos observar, a regressão linear corresponde ao subgráfico com a relação direta. Porém, não há como saber se as demais relações estão ocorrendo. Por exemplo, poderíamos ter em nossa relação direta um confundidor, que é uma variável com efeito tanto em <img src="https://latex.codecogs.com/png.latex?x"> quanto em <img src="https://latex.codecogs.com/png.latex?y"> e que, portanto, leva à observação da relação entre <img src="https://latex.codecogs.com/png.latex?x"> e <img src="https://latex.codecogs.com/png.latex?y"> pelo modelo. Essa pode ser uma das explicações para as correlações espúrias. Também podemos ter uma variável mediadora, ou seja, responsável por mediar uma parte da variação entre <img src="https://latex.codecogs.com/png.latex?x"> e <img src="https://latex.codecogs.com/png.latex?y">, além da variação direta. E, por fim, temos a moderação, em que outra variável pode estar moderando a relação entre <img src="https://latex.codecogs.com/png.latex?x"> e <img src="https://latex.codecogs.com/png.latex?y">. Em todos os casos, se estamos usando apenas uma regressão linear simples, podemos estar suscetíveis a não observar essa variável oculta. Por isso: regressão não implica causa.</p>
<div id="fig-dag" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-dag-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="plot_causa.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-16" title="Figura&nbsp;11: Possíveis relações entre variáveis"><img src="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/plot_causa.jpeg" class="img-fluid figure-img"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-dag-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;11: Possíveis relações entre variáveis
</figcaption>
</figure>
</div>
<p>Ainda assim, com os avanços dos estudos, essas variáveis ocultas podem ir sendo descobertas e aprimorando a nossa teoria… Incrível!</p>
<div class="callout callout-style-default callout-important callout-titled" title="Ajuda estatística">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-4-contents" aria-controls="callout-4" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Importante</span>Ajuda estatística
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-4" class="callout-4-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>Boa parte dos cálculos e das dúvidas foi resolvida graças à ajuda de Diogo Bolzan (um quase estatístico da UFRGS).</p>
</div>
</div>
</div>



</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> De volta ao topo</a><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">Referências</h2><div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-altay" class="csl-entry">
Altay L. Souza. 2025. <em>Regressão Linear III - Descrever, Explicar e Predizer na RLinear</em>. <a href="https://www.youtube.com/watch?v=mQpnsYh4JQA" class="uri">Https://www.youtube.com/watch?v=mQpnsYh4JQA</a>.
</div>
<div id="ref-b053c0e7-e2d5-3dd5-93ba-a1adab8d3d90" class="csl-entry">
Box, Joan Fisher. 1981. <span>«Gosset, Fisher, and the t Distribution»</span>. <em>The American Statistician</em> 35 (2): 61–66. <a href="http://www.jstor.org/stable/2683142">http://www.jstor.org/stable/2683142</a>.
</div>
<div id="ref-alma991020382257805181" class="csl-entry">
Douglas C. Montgomery, G. Geoffrey Vining, Elizabeth A. Peck. 2021. <em>Introduction to Linear Regression Analysis</em>. Wiley. <a href="https://www.perlego.com/book/2237423/introduction-to-linear-regression-analysis-pdf">https://www.perlego.com/book/2237423/introduction-to-linear-regression-analysis-pdf</a>.
</div>
<div id="ref-guimaraes2022regression" class="csl-entry">
Guimarães, Alysson. 2022. <span>«Princípios da Regressão Linear»</span>. Em <em>https://k3ybladewielder.medium.com</em>. <a href="https://k3ybladewielder.medium.com/p-3ab26a7b4340">https://k3ybladewielder.medium.com/p-3ab26a7b4340</a>.
</div>
<div id="ref-kasza" class="csl-entry">
Kasza, Jessica, e Rory Wolfe. 2014. <span>«Interpretation of commonly used statistical regression models»</span>. <em>Respirology</em> 19 (1): 14–21. https://doi.org/<a href="https://doi.org/10.1111/resp.12221">https://doi.org/10.1111/resp.12221</a>.
</div>
<div id="ref-setosa_linear_regression" class="csl-entry">
Setosa. 2018. <em>Linear Regression</em>. <a href="https://setosa.io/ev/linear-regression/" class="uri">Https://setosa.io/ev/linear-regression/</a>.
</div>
<div id="ref-shmueli" class="csl-entry">
Shmueli, Galit. 2010. <span>«<span>To Explain or to Predict?</span>»</span> <em>Statistical Science</em> 25 (3): 289–310. <a href="https://doi.org/10.1214/10-STS330">https://doi.org/10.1214/10-STS330</a>.
</div>
<div id="ref-joram_soch_2025_18096132" class="csl-entry">
<span class="nocase">Soch, Joram, The Book of Statistical Proofs, Karahan Sarıtaş, et al.</span> 2025. <em>StatProofBook/StatProofBook.github.io: StatProofBook 2025</em>. Versão 2025. Zenodo, released dezembro. <a href="https://doi.org/10.5281/zenodo.18096132">https://doi.org/10.5281/zenodo.18096132</a>.
</div>
<div id="ref-wilber2022linear" class="csl-entry">
Wilber, Jared. 2022. <em>Linear Regression: A Visual Introduction to (Almost) Everything You Should Know</em>. <a href="https://mlu-explain.github.io/linear-regression/" class="uri">Https://mlu-explain.github.io/linear-regression/</a>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citação</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{frosi2026,
  author = {Frosi, Gustavo},
  title = {Do ponto à linha: criando uma regressão para além de clicar
    em botão},
  date = {2026-07-06},
  url = {https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/},
  doi = {10.59350/xp1jx-gs759},
  langid = {pt}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cite este trabalho como:</div><div id="ref-frosi2026" class="csl-entry quarto-appendix-citeas">
Frosi, Gustavo. 2026. <span>“Do ponto à linha: criando uma regressão
para além de clicar em botão.”</span> July 6. <a href="https://doi.org/10.59350/xp1jx-gs759">https://doi.org/10.59350/xp1jx-gs759</a>.
</div></div></section></div> ]]></description>
  <category>R</category>
  <category>Regressão Linear</category>
  <category>Estatística</category>
  <guid>https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/</guid>
  <pubDate>Mon, 06 Jul 2026 03:00:00 GMT</pubDate>
  <media:content url="https://gustavofrosi.com.br/recap/2026-07-06-reg-line-conta/Reg_mao.jpeg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Gráficos para Revista Brasileira de Ciência do Solo</title>
  <dc:creator>Gustavo Frosi</dc:creator>
  <link>https://gustavofrosi.com.br/recap/2025-08-31-RBCS-no-ggplo2/</link>
  <description><![CDATA[ 





<section id="alguns-padrões" class="level1">
<h1>Alguns padrões</h1>
<p>A <em>Revista Brasileira de Ciência do Solo</em> preza por um padrão gráfico nos artigos publicados. Para isso, há um guia com todas as exigências que os autores devem atender para manter a identidade visual. Este texto é um guia de como realizar essas alterações utilizando gráficos e figuras desenvolvidos com a linguagem R.</p>
<section id="a-fonte" class="level2">
<h2 class="anchored" data-anchor-id="a-fonte">A fonte</h2>
<p><strong>DejaVu</strong> é a família da fonte <strong>DejaVu Sans Condensed</strong>, a qual deve ser utilizada na criação das figuras. A família de fontes <strong>DejaVu</strong> está em domínio público, podendo ser baixada e até modificada por qualquer pessoa. Isso é uma vantagem, pois seu download pode ser feito de forma rápida e simples. Uma das alternativas é obtê-la no site <a href="https://pt.fonts2u.com/dejavu-sans-condensed.fonte">fonts2u</a>.</p>
<p>A Tabela&nbsp;1 mostra o mesmo texto escrito com as fontes Arial e DejaVu, permitindo observar as principais diferenças entre elas.</p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" 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>(gt)</span>
<span id="cb1-2"></span>
<span id="cb1-3">texto <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;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Arial =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A ciência do solo é o estudo do solo da Terra e de outros planetas, usando teorias e conhecimentos em evolução para entender seu papel na sustentação do funcionamento do ecossistema, enfrentando desafios ambientais e apoiando a humanidade."</span>,</span>
<span id="cb1-4">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">DejaVu =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A ciência do solo é o estudo do solo da Terra e de outros planetas, usando teorias e conhecimentos em evolução para entender seu papel na sustentação do funcionamento do ecossistema, enfrentando desafios ambientais e apoiando a humanidade."</span>)</span>
<span id="cb1-5"></span>
<span id="cb1-6">texto <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb1-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gt</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb1-8">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># tab_header(</span></span>
<span id="cb1-9">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   # title = md("**Diferenças entre Arial e DejaVu**")</span></span>
<span id="cb1-10">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ) |&gt; </span></span>
<span id="cb1-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tab_source_note</span>(</span>
<span id="cb1-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source_note =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">md</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fonte: https://doi.org/10.1016/j.soisec.2025.100176"</span>)</span>
<span id="cb1-13">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb1-14">   <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tab_style</span>(</span>
<span id="cb1-15">    <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;">cell_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">font =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Arial"</span>),</span>
<span id="cb1-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">locations =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cells_body</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">columns =</span> Arial)</span>
<span id="cb1-17">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tab_style</span>(</span>
<span id="cb1-19">    <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;">cell_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">font =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DejaVu Sans"</span>),</span>
<span id="cb1-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">locations =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cells_body</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">columns =</span> DejaVu)</span>
<span id="cb1-21">  )</span></code></pre></div></div>
</details>
<div id="tbl-comp" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-comp-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Tabela&nbsp;1: Comparação das fontes Arial e DejaVu
</figcaption>
<div aria-describedby="tbl-comp-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<div id="eqvvsgdxve" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#eqvvsgdxve table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#eqvvsgdxve thead, #eqvvsgdxve tbody, #eqvvsgdxve tfoot, #eqvvsgdxve tr, #eqvvsgdxve td, #eqvvsgdxve th {
  border-style: none;
}

#eqvvsgdxve p {
  margin: 0;
  padding: 0;
}

#eqvvsgdxve .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#eqvvsgdxve .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#eqvvsgdxve .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#eqvvsgdxve .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#eqvvsgdxve .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#eqvvsgdxve .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#eqvvsgdxve .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#eqvvsgdxve .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#eqvvsgdxve .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#eqvvsgdxve .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#eqvvsgdxve .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#eqvvsgdxve .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#eqvvsgdxve .gt_spanner_row {
  border-bottom-style: hidden;
}

#eqvvsgdxve .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#eqvvsgdxve .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#eqvvsgdxve .gt_from_md > :first-child {
  margin-top: 0;
}

#eqvvsgdxve .gt_from_md > :last-child {
  margin-bottom: 0;
}

#eqvvsgdxve .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#eqvvsgdxve .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#eqvvsgdxve .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#eqvvsgdxve .gt_row_group_first td {
  border-top-width: 2px;
}

#eqvvsgdxve .gt_row_group_first th {
  border-top-width: 2px;
}

#eqvvsgdxve .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#eqvvsgdxve .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#eqvvsgdxve .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#eqvvsgdxve .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#eqvvsgdxve .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#eqvvsgdxve .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#eqvvsgdxve .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#eqvvsgdxve .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#eqvvsgdxve .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#eqvvsgdxve .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#eqvvsgdxve .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#eqvvsgdxve .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#eqvvsgdxve .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#eqvvsgdxve .gt_left {
  text-align: left;
}

#eqvvsgdxve .gt_center {
  text-align: center;
}

#eqvvsgdxve .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#eqvvsgdxve .gt_font_normal {
  font-weight: normal;
}

#eqvvsgdxve .gt_font_bold {
  font-weight: bold;
}

#eqvvsgdxve .gt_font_italic {
  font-style: italic;
}

#eqvvsgdxve .gt_super {
  font-size: 65%;
}

#eqvvsgdxve .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#eqvvsgdxve .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#eqvvsgdxve .gt_indent_1 {
  text-indent: 5px;
}

#eqvvsgdxve .gt_indent_2 {
  text-indent: 10px;
}

#eqvvsgdxve .gt_indent_3 {
  text-indent: 15px;
}

#eqvvsgdxve .gt_indent_4 {
  text-indent: 20px;
}

#eqvvsgdxve .gt_indent_5 {
  text-indent: 25px;
}

#eqvvsgdxve .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#eqvvsgdxve div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table cell caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="Arial" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">Arial</th>
<th id="DejaVu" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">DejaVu</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="Arial" style="font-family: Arial">A ciência do solo é o estudo do solo da Terra e de outros planetas, usando teorias e conhecimentos em evolução para entender seu papel na sustentação do funcionamento do ecossistema, enfrentando desafios ambientais e apoiando a humanidade.</td>
<td class="gt_row gt_left" headers="DejaVu" style="font-family: 'DejaVu Sans'">A ciência do solo é o estudo do solo da Terra e de outros planetas, usando teorias e conhecimentos em evolução para entender seu papel na sustentação do funcionamento do ecossistema, enfrentando desafios ambientais e apoiando a humanidade.</td>
</tr>
</tbody><tfoot>
<tr class="gt_sourcenotes odd">
<td colspan="2" class="gt_sourcenote">Fonte: https://doi.org/10.1016/j.soisec.2025.100176</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
</figure>
</div>
</div>
</section>
<section id="as-cores" class="level2">
<h2 class="anchored" data-anchor-id="as-cores">As cores</h2>
<p>A <em>RBCS</em> possui uma paleta própria com 9 cores disponíveis para os gráficos. Na Figura&nbsp;1 são apresentadas as cores e seus respectivos códigos hexadecimais.</p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" 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>(ggplot2)</span>
<span id="cb2-2"></span>
<span id="cb2-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># vetor de cores</span></span>
<span id="cb2-4">cores <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>
<span id="cb2-5">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#9e2943"</span>,</span>
<span id="cb2-6">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0a6c69"</span>,</span>
<span id="cb2-7">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#75a741"</span>,</span>
<span id="cb2-8">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d18525"</span>,</span>
<span id="cb2-9">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d86c67"</span>,</span>
<span id="cb2-10">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5ab5b2"</span>,</span>
<span id="cb2-11">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#b1d369"</span>,</span>
<span id="cb2-12">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#711011"</span>,</span>
<span id="cb2-13">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#033a39"</span></span>
<span id="cb2-14">)</span>
<span id="cb2-15"></span>
<span id="cb2-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># cria um data frame com posição e cores</span></span>
<span id="cb2-17">df <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;">data.frame</span>(</span>
<span id="cb2-18">  <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;">seq_along</span>(cores),</span>
<span id="cb2-19">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb2-20">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cor =</span> cores</span>
<span id="cb2-21">)</span>
<span id="cb2-22"></span>
<span id="cb2-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># plota quadrados</span></span>
<span id="cb2-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df, <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;">fill =</span> cor)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_tile</span>(<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;">"white"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</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;">label =</span> cores), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</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;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_identity</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_fixed</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_void</span>()</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="fig-paleta" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-paleta-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2025-08-31-RBCS-no-ggplo2/index_files/figure-html/fig-paleta-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-paleta-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;1: Paleta de cores da RBCS
</figcaption>
</figure>
</div>
</div>
</div>
</section>
</section>
<section id="reproduzindo-o-padrão-rbcs-no-r" class="level1">
<h1>Reproduzindo o padrão RBCS no R</h1>
<p>Para implementar essas configurações, serão utilizados os seguintes pacotes do R:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" 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;">library</span>(tidyverse) </span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(systemfonts)</span>
<span id="cb3-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(extrafont)</span>
<span id="cb3-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(patchwork)</span></code></pre></div></div>
</div>
<section id="verificando-a-fonte" class="level2">
<h2 class="anchored" data-anchor-id="verificando-a-fonte">Verificando a fonte</h2>
<p>Após baixar e instalar a fonte, é necessário torná-la disponível para uso no R. Isso é feito carregando as fontes do sistema com a função abaixo:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># importar fontes</span></span>
<span id="cb4-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">font_import</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>Importing fonts may take a few minutes, depending on the number of fonts and the speed of the system.
Continue? [y/n] </code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>Exiting.</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>A função <code>font_import()</code> é utilizada apenas um vez, após a instalação da fonte no computador.</p>
</div>
</div>
<p>Após o carregamento, pode ser realizado o registro de fontes que ainda não foram registradas.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># registrar fontes</span></span>
<span id="cb7-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">loadfonts</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">device =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"win"</span>)</span></code></pre></div></div>
</div>
<p>Agora, as fontes podem ser carregadas, e uma estrutura condicional pode ser feita para verificar se entre as fontes disponíveis está a <strong>DejaVu</strong>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fontes detectadas no sistema</span></span>
<span id="cb8-2">fonts <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;">system_fonts</span>()</span>
<span id="cb8-3"></span>
<span id="cb8-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># estrutura lógica de seleção</span></span>
<span id="cb8-5"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(fonts <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;">"DejaVuSansCondensed"</span>)) {</span>
<span id="cb8-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fonte instalada!!"</span>)</span>
<span id="cb8-7">}<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>{</span>
<span id="cb8-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fonte não encontrada!!"</span>)</span>
<span id="cb8-9">}</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "Fonte instalada!!"</code></pre>
</div>
</div>
</section>
<section id="cores" class="level2">
<h2 class="anchored" data-anchor-id="cores">Cores</h2>
<p>Para utilizar as cores, basta criar um vetor com os códigos hexadecimais (Figura&nbsp;1).</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">cores <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>
<span id="cb10-2">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#9e2943"</span>,</span>
<span id="cb10-3">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0a6c69"</span>,</span>
<span id="cb10-4">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#75a741"</span>,</span>
<span id="cb10-5">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d18525"</span>,</span>
<span id="cb10-6">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d86c67"</span>,</span>
<span id="cb10-7">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5ab5b2"</span>,</span>
<span id="cb10-8">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#b1d369"</span>,</span>
<span id="cb10-9">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#711011"</span>,</span>
<span id="cb10-10">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#033a39"</span></span>
<span id="cb10-11">)</span></code></pre></div></div>
</div>
</section>
<section id="exemplo-de-uso" class="level2">
<h2 class="anchored" data-anchor-id="exemplo-de-uso">Exemplo de uso</h2>
<p>A seguir, apresento um exemplo de como tudo isso pode ser adicionado de forma simples aos gráficos.</p>
<p>Para ilustrar, criei dados fictícios de um experimento comum de dose e resposta. Neste exemplo, considero 9 tratamentos, com 10 repetições, 5 doses e uma variável chamada resposta. Os valores não possuem significado real, servindo apenas como exemplo.</p>
</section>
<section id="visualização" class="level2">
<h2 class="anchored" data-anchor-id="visualização">Visualização</h2>
<p>Para aplicar a fonte a todo o texto do gráfico, basta definir o nome da fonte na configuração de temas do {ggplot2}.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_family =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dejavu Sans"</span>)</span></code></pre></div></div>
</div>
<p>Caso, o tema utilizado seja o “base”, utilize:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<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;">"Dejavu Sans"</span>))</span></code></pre></div></div>
</div>
<p>Já as cores podem ser adicionadas por meio de uma escala manual, passando o vetor como parâmetro de <code>values</code> na função <code>scale_color_manual()</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb13-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb13-2">  <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> tratamento, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> resposta, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>(dose)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(</span>
<span id="cb13-4">    <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;">"errorbar"</span>,</span>
<span id="cb13-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb13-6">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(</span>
<span id="cb13-8">    <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;">"point"</span>,</span>
<span id="cb13-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>),</span>
<span id="cb13-10">    <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;">2</span></span>
<span id="cb13-11">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> cores)</span></code></pre></div></div>
</div>
<p>Além disso, a RBCS solicita que os gráficos sejam enviados em formato vetorial, como SVG. Para salvar um gráfico do {ggplot2} nesse formato, basta utilizar a função <code>ggsave()</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb14-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">filename =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fig_ex.svg"</span>, </span>
<span id="cb14-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, </span>
<span id="cb14-3">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, </span>
<span id="cb14-4">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">units =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm"</span>, </span>
<span id="cb14-5">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">950</span>)</span></code></pre></div></div>
</div>
<p>Abaixo, reúno os dados apresentados em três gráficos distintos, já utilizando as configurações da <em>RBCS</em>.</p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ponto com barra de erro</span></span>
<span id="cb15-2">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>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-3">  <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> tratamento, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> resposta, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>(dose)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(</span>
<span id="cb15-5">    <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;">"errorbar"</span>,</span>
<span id="cb15-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb15-7">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(</span>
<span id="cb15-9">    <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;">"point"</span>,</span>
<span id="cb15-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>),</span>
<span id="cb15-11">    <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;">2</span></span>
<span id="cb15-12">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> cores) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb15-15">    <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;">"Tratamento"</span>,</span>
<span id="cb15-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Resposta"</span>,</span>
<span id="cb15-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dose"</span>,</span>
<span id="cb15-18">    <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;">"Gráfico de pontos de exemplo"</span></span>
<span id="cb15-19">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_family =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dejavu Sans"</span>)</span>
<span id="cb15-21"></span>
<span id="cb15-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># colunas</span></span>
<span id="cb15-23">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>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-24">  <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> dose, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> resposta, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>(tratamento)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(</span>
<span id="cb15-26">    <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;">"col"</span>,</span>
<span id="cb15-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>()</span>
<span id="cb15-28">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> cores) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb15-31">    <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;">"Dose"</span>,</span>
<span id="cb15-32">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Resposta"</span>,</span>
<span id="cb15-33">    <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;">"Tratamento"</span>,</span>
<span id="cb15-34">    <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;">"Gráfico de barras de exemplo"</span></span>
<span id="cb15-35">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-36">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_family =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dejavu Sans"</span>)</span>
<span id="cb15-37"></span>
<span id="cb15-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># linhas</span></span>
<span id="cb15-39">p3 <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>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-40">  <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> dose, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> resposta, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>(tratamento)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-41">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(<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;">linewidth =</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="cb15-42">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> cores) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-43">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb15-44">    <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;">"Dose"</span>,</span>
<span id="cb15-45">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Resposta"</span>,</span>
<span id="cb15-46">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tratamento"</span>,</span>
<span id="cb15-47">    <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;">"Gráfico de linhas de exemplo"</span></span>
<span id="cb15-48">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-49">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_family =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dejavu Sans"</span>)</span>
<span id="cb15-50"></span>
<span id="cb15-51">pt1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (p1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> p2) <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;">plot_layout</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">widths =</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;">55</span>, .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>))</span>
<span id="cb15-52"></span>
<span id="cb15-53">ptt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pt1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> p3</span>
<span id="cb15-54"></span>
<span id="cb15-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ggsave(filename = "exemplo_gra.png",</span></span>
<span id="cb15-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#        width = 10,</span></span>
<span id="cb15-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#        height = 8,</span></span>
<span id="cb15-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#        dpi = 1200)</span></span></code></pre></div></div>
</details>
</div>
<p><img src="https://gustavofrosi.com.br/recap/2025-08-31-RBCS-no-ggplo2/ima/exemplo_gra.png" class="img-fluid"></p>
</section>
</section>
<section id="criando-um-snippet" class="level1">
<h1>Criando um snippet</h1>
<p>Os snippets são blocos de código que podem ser chamados rapidamente no corpo do script, utilizando palavras-chave. Exemplos são <code>if</code>, <code>for</code> e <code>fun</code>. Ao digitar essas palavras no RStudio, o autocomplete sugere o snippet que insere automaticamente a estrutura completa da função, otimizando o tempo.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><video src="ima/2025-08-09-16-56-27.mkv" class="img-fluid" controls=""><a href="ima/2025-08-09-16-56-27.mkv">Video</a></video></p>
<figcaption>Exemplo de uso de snippet</figcaption>
</figure>
</div>
<section id="snippet-rbcs" class="level2">
<h2 class="anchored" data-anchor-id="snippet-rbcs">Snippet rbcs</h2>
<p>O vídeo abaixo mostra o processo de criação de um snippet baseado no código acima, como chamá-lo no script e, assim, automatizar as configurações de gráficos para a <em>RBCS</em>.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><video src="ima/snippet_rbcs.mkv" class="img-fluid" controls=""><a href="ima/snippet_rbcs.mkv">Video</a></video></p>
<figcaption>Exemplo de snippet RBCS</figcaption>
</figure>
</div>
<p>Agora, sempre que for necessário formatar gráficos de acordo com o padrão da <em>RBCS</em>, basta escrever <code>rbcs</code> e pressionar enter no RStudio: as configurações básicas já serão inseridas no código.</p>


</section>
</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> De volta ao topo</a><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citação</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{frosi2025,
  author = {Frosi, Gustavo},
  title = {Gráficos para Revista Brasileira de Ciência do Solo},
  date = {2025-08-31},
  url = {https://gustavofrosi.com.br/recap/2025-08-31-RBCS-no-ggplo2/},
  doi = {10.59350/tx9q9-mqy45},
  langid = {pt}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cite este trabalho como:</div><div id="ref-frosi2025" class="csl-entry quarto-appendix-citeas">
Frosi, Gustavo. 2025. <span>“Gráficos para Revista Brasileira de Ciência
do Solo.”</span> August 31. <a href="https://doi.org/10.59350/tx9q9-mqy45">https://doi.org/10.59350/tx9q9-mqy45</a>.
</div></div></section></div> ]]></description>
  <category>R</category>
  <category>Solos</category>
  <category>RBCS</category>
  <category>ggplot2</category>
  <guid>https://gustavofrosi.com.br/recap/2025-08-31-RBCS-no-ggplo2/</guid>
  <pubDate>Sun, 31 Aug 2025 03:00:00 GMT</pubDate>
  <media:content url="https://gustavofrosi.com.br/recap/2025-08-31-RBCS-no-ggplo2/th.png" medium="image" type="image/png" height="78" width="144"/>
</item>
<item>
  <title>Trabalhos - XV Reunião Sul Brasileira de Ciência do Solo</title>
  <dc:creator>Gustavo Frosi</dc:creator>
  <link>https://gustavofrosi.com.br/recap/2025-01-05-RSBCS-2024/</link>
  <description><![CDATA[ 





<section id="introdução" class="level1">
<h1>Introdução</h1>
<p>Para mais informações acesse o site: <a href="https://www.rsbcs2024.com.br/" class="uri">https://www.rsbcs2024.com.br/</a></p>
</section>
<section id="pacotes" class="level1">
<h1>Pacotes</h1>
<p>Para essa análise vou utilizar os seguintes pacotes do R</p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" 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>(tidyverse)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(pdftools)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggtext)</span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(gt)</span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(patchwork)</span></code></pre></div></div>
</details>
</div>
</section>
<section id="dados" class="level1">
<h1>Dados</h1>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">doc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"anais-2024.pdf"</span></span>
<span id="cb2-2"></span>
<span id="cb2-3">texto <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pdftools<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;">pdf_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pdf =</span> doc)</span>
<span id="cb2-4"></span>
<span id="cb2-5">df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> texto[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</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;">18</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb2-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?&lt;=</span><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;">d)</span><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;">n"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb2-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unlist</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enframe</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"linha"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb2-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(linha <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;">""</span>)</span>
<span id="cb2-10"></span>
<span id="cb2-11">df2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df[<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;">seq</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;">18</span>),]</span>
<span id="cb2-12">df2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df2[<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;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">321</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">320</span>),]</span>
<span id="cb2-13"></span>
<span id="cb2-14">base <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">separate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> linha, </span>
<span id="cb2-15">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">into =</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;">"trabalho"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pag"</span>), </span>
<span id="cb2-16">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><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;">.{2,}</span><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;">s*"</span>)</span>
<span id="cb2-17"></span>
<span id="cb2-18">writexl<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;">write_xlsx</span>(base, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">path =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"anais.xlsx"</span>)</span></code></pre></div></div>
</details>
</div>
</section>
<section id="visualização" class="level1">
<h1>Visualização</h1>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> readxl<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;">read_excel</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"anais.xlsx"</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;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pag =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(pag))</span>
<span id="cb3-3"></span>
<span id="cb3-4">area <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(trabalho, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ÁREA"</span>))</span>
<span id="cb3-5"></span>
<span id="cb3-6">df_filter <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;">anti_join</span>(df, area, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pag"</span>)</span>
<span id="cb3-7"></span>
<span id="cb3-8">areas <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> </span>
<span id="cb3-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb3-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">code =</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;">"Biologia"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Educação"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Manejo"</span>,</span>
<span id="cb3-11">             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gênese"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Física"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Química"</span>),</span>
<span id="cb3-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nome =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb3-13">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BIOLOGIA DO SOLO, CICLOS BIOGEOQUÍMICOS, </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;">BIOINSUMOS, QUALIDADE E SAÚDE DO SOLO"</span>,</span>
<span id="cb3-14">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EDUCAÇÃO, SOCIOLOGIA, PÚBLICA E </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;">SEGURANÇA ALIMENTAR"</span>,</span>
<span id="cb3-15">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MANEJO E CONSERVAÇÃO DO SOLO E DA ÁGUA, </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;">PLANEJAMENTO DO USO DA TERRA, HIDROLOGIA"</span>,</span>
<span id="cb3-16">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MINERALOGIA, GÊNESE, MORFOLOGIA, </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;">LEVANTAMENTO, CLASSIFICAÇÃO DO SOLO, </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;">PEDOMETRIA E PALEOPEDOLOGIA"</span>,</span>
<span id="cb3-17">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PEDOFUNÇÕES, PROPRIEDADES E </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;">PROCESSOS FÍSICOS DO SOLO"</span>,</span>
<span id="cb3-18">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"QUÍMICA, FERTILIDADE, NUTRIÇÃO DE PLANTAS, </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;"> CORRETIVOS E FERTILIZANTES"</span></span>
<span id="cb3-19">      )</span>
<span id="cb3-20">    )</span>
<span id="cb3-21"></span>
<span id="cb3-22">base <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df_filter <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb3-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;">area =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb3-24">    pag <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">103</span> <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;">"Biologia"</span>,</span>
<span id="cb3-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">between</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> pag, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">left =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">103</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">122</span>) <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;">"Educação"</span>,</span>
<span id="cb3-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">between</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> pag, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">left =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">123</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">186</span>) <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;">"Manejo"</span>,</span>
<span id="cb3-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">between</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> pag, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">left =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">187</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">204</span>) <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;">"Gênese"</span>,</span>
<span id="cb3-28">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">between</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> pag, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">left =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">205</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">224</span>) <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;">"Física"</span>,</span>
<span id="cb3-29">    pag <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;">224</span> <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;">"Química"</span>,</span>
<span id="cb3-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.default =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span></span>
<span id="cb3-31">  ),</span>
<span id="cb3-32">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">area =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_title</span>(area))</span></code></pre></div></div>
</details>
</div>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">areas <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb4-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gt</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb4-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tab_header</span>(</span>
<span id="cb4-4">    <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;">md</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Divisão das áreas de pesquisa na XV RSBCS**"</span>),</span>
<span id="cb4-5">    <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;">md</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Reunião Sul Brasileira de Ciência do Solo"</span>)</span>
<span id="cb4-6">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb4-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cols_label</span>(</span>
<span id="cb4-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">code =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Código"</span>,</span>
<span id="cb4-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nome =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Área"</span></span>
<span id="cb4-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb4-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tab_source_note</span>(</span>
<span id="cb4-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source_note =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">md</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Source: www.rsbcs2024.com.br"</span>)</span>
<span id="cb4-13">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="cnzyncpibw" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#cnzyncpibw table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#cnzyncpibw thead, #cnzyncpibw tbody, #cnzyncpibw tfoot, #cnzyncpibw tr, #cnzyncpibw td, #cnzyncpibw th {
  border-style: none;
}

#cnzyncpibw p {
  margin: 0;
  padding: 0;
}

#cnzyncpibw .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#cnzyncpibw .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#cnzyncpibw .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#cnzyncpibw .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#cnzyncpibw .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#cnzyncpibw .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#cnzyncpibw .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#cnzyncpibw .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#cnzyncpibw .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#cnzyncpibw .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#cnzyncpibw .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#cnzyncpibw .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#cnzyncpibw .gt_spanner_row {
  border-bottom-style: hidden;
}

#cnzyncpibw .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#cnzyncpibw .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#cnzyncpibw .gt_from_md > :first-child {
  margin-top: 0;
}

#cnzyncpibw .gt_from_md > :last-child {
  margin-bottom: 0;
}

#cnzyncpibw .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#cnzyncpibw .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#cnzyncpibw .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#cnzyncpibw .gt_row_group_first td {
  border-top-width: 2px;
}

#cnzyncpibw .gt_row_group_first th {
  border-top-width: 2px;
}

#cnzyncpibw .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#cnzyncpibw .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#cnzyncpibw .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#cnzyncpibw .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#cnzyncpibw .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#cnzyncpibw .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#cnzyncpibw .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#cnzyncpibw .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#cnzyncpibw .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#cnzyncpibw .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#cnzyncpibw .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#cnzyncpibw .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#cnzyncpibw .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#cnzyncpibw .gt_left {
  text-align: left;
}

#cnzyncpibw .gt_center {
  text-align: center;
}

#cnzyncpibw .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#cnzyncpibw .gt_font_normal {
  font-weight: normal;
}

#cnzyncpibw .gt_font_bold {
  font-weight: bold;
}

#cnzyncpibw .gt_font_italic {
  font-style: italic;
}

#cnzyncpibw .gt_super {
  font-size: 65%;
}

#cnzyncpibw .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#cnzyncpibw .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#cnzyncpibw .gt_indent_1 {
  text-indent: 5px;
}

#cnzyncpibw .gt_indent_2 {
  text-indent: 10px;
}

#cnzyncpibw .gt_indent_3 {
  text-indent: 15px;
}

#cnzyncpibw .gt_indent_4 {
  text-indent: 20px;
}

#cnzyncpibw .gt_indent_5 {
  text-indent: 25px;
}

#cnzyncpibw .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#cnzyncpibw div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading header">
<td colspan="2" class="gt_heading gt_title gt_font_normal"><strong>Divisão das áreas de pesquisa na XV RSBCS</strong></td>
</tr>
<tr class="gt_heading even">
<td colspan="2" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Reunião Sul Brasileira de Ciência do Solo</td>
</tr>
<tr class="gt_col_headings header">
<th id="code" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">Código</th>
<th id="nome" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">Área</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="code">Biologia</td>
<td class="gt_row gt_left" headers="nome">BIOLOGIA DO SOLO, CICLOS BIOGEOQUÍMICOS, BIOINSUMOS, QUALIDADE E SAÚDE DO SOLO</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="code">Educação</td>
<td class="gt_row gt_left" headers="nome">EDUCAÇÃO, SOCIOLOGIA, PÚBLICA E SEGURANÇA ALIMENTAR</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="code">Manejo</td>
<td class="gt_row gt_left" headers="nome">MANEJO E CONSERVAÇÃO DO SOLO E DA ÁGUA, PLANEJAMENTO DO USO DA TERRA, HIDROLOGIA</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="code">Gênese</td>
<td class="gt_row gt_left" headers="nome">MINERALOGIA, GÊNESE, MORFOLOGIA, LEVANTAMENTO, CLASSIFICAÇÃO DO SOLO, PEDOMETRIA E PALEOPEDOLOGIA</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="code">Física</td>
<td class="gt_row gt_left" headers="nome">PEDOFUNÇÕES, PROPRIEDADES E PROCESSOS FÍSICOS DO SOLO</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="code">Química</td>
<td class="gt_row gt_left" headers="nome">QUÍMICA, FERTILIDADE, NUTRIÇÃO DE PLANTAS, CORRETIVOS E FERTILIZANTES</td>
</tr>
</tbody><tfoot>
<tr class="gt_sourcenotes odd">
<td colspan="2" class="gt_sourcenote">Source: www.rsbcs2024.com.br</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">github_icon <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;#xf09b"</span></span>
<span id="cb5-2">git_gf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FGu5tav0"</span></span>
<span id="cb5-3">social_caption <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> glue<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;">glue</span>(</span>
<span id="cb5-4">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;span style='font-family:</span><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;">Font Awesome 6 Brands</span><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;">;'&gt;{github_icon};&lt;/span&gt;</span></span>
<span id="cb5-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  &lt;span style='color: #000000'&gt;{git_gf}&lt;/span&gt;&lt;br&gt; Dados: rsbcs2024.com.br"</span></span>
<span id="cb5-6">)</span>
<span id="cb5-7"></span>
<span id="cb5-8">p1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> base <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(area) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</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;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fct_reorder</span>(area, n), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> n)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(</span>
<span id="cb5-13">    <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;">"#3d643b"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#317a31"</span>,</span>
<span id="cb5-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span></span>
<span id="cb5-15">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_identity</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping=</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;">y=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x=</span>area, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label=</span>area),</span>
<span id="cb5-18">            <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;">"gray20"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust=</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-19">  ggtext<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;">geom_textbox</span>(</span>
<span id="cb5-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb5-21">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> n,</span>
<span id="cb5-22">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb5-23">        n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</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;">0</span>,</span>
<span id="cb5-24">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</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;">1</span></span>
<span id="cb5-25">      ),</span>
<span id="cb5-26">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">halign =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb5-27">        n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</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;">0</span>,</span>
<span id="cb5-28">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</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;">1</span></span>
<span id="cb5-29">      ),</span>
<span id="cb5-30">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb5-31">        n <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;">50</span> <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;">"#FFFFFF"</span>,</span>
<span id="cb5-32">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span> <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;">"#36200d"</span></span>
<span id="cb5-33">      )</span>
<span id="cb5-34">    ),</span>
<span id="cb5-35">    <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;">4</span>,</span>
<span id="cb5-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb5-37">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">box.colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb5-38">    <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;">"Cabin"</span>,</span>
<span id="cb5-39">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span></span>
<span id="cb5-40">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-41">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> F, <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="cb5-42">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb5-43">    <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;">' &lt;span style = "color:#317a31"&gt; Resumos apresentados na&lt;/span&gt;&lt;span style = "color:#36200d"&gt; XV RSBCS - 2024&lt;/span&gt;'</span>,</span>
<span id="cb5-44">    <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 resumos apresentados por área"</span>,</span>
<span id="cb5-45">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nº de trabalhos apresentados"</span>,</span>
<span id="cb5-46">    <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;">element_blank</span>(),</span>
<span id="cb5-47">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> social_caption</span>
<span id="cb5-48">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-49">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-50">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb5-51">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<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;">"#f5f5f2"</span>, </span>
<span id="cb5-52">                                   <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;">"#f5f5f2"</span>),</span>
<span id="cb5-53">    <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;">"none"</span>,</span>
<span id="cb5-54">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> ggtext<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;">element_textbox_simple</span>(</span>
<span id="cb5-55">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rel</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.3</span>),</span>
<span id="cb5-56">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>,</span>
<span id="cb5-57">      <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;">"Enriqueta"</span>,</span>
<span id="cb5-58">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lineheight =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb5-59">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">margin =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">margin</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</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;">0</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lines"</span>),</span>
<span id="cb5-60">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">halign =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb5-61">    ),</span>
<span id="cb5-62">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> ggtext<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;">element_textbox_simple</span>(</span>
<span id="cb5-63">      <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;">"Cabin"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rel</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), </span>
<span id="cb5-64">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lineheight =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb5-65">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">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;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lines"</span>)),</span>
<span id="cb5-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.caption =</span> ggtext<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;">element_textbox_simple</span>(</span>
<span id="cb5-67">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rel</span>(.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)),</span>
<span id="cb5-68">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid.major =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-69">    <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="cb5-70">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-71">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.ticks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>()</span>
<span id="cb5-72">  ) </span>
<span id="cb5-73"></span>
<span id="cb5-74"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ggsave(plot = p1,filename = "resumos.jpeg",</span></span>
<span id="cb5-75"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># width = 4, height = 4, dpi = 600)</span></span></code></pre></div></div>
</details>
</div>
<p><img src="https://gustavofrosi.com.br/recap/2025-01-05-RSBCS-2024/resumos.jpeg" class="img-fluid" style="width:80.0%"></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>Os códigos apresentados foram produzidos sem critérios de qualidade. Melhorias ainda podem ser feitas.</p>
</div>
</div>


</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> De volta ao topo</a><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citação</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{frosi2025,
  author = {Frosi, Gustavo},
  title = {Trabalhos - XV Reunião Sul Brasileira de Ciência do Solo},
  date = {2025-01-05},
  url = {https://gustavofrosi.com.br/recap/2025-01-05-RSBCS-2024/},
  doi = {10.59350/97z3m-yvf13},
  langid = {pt}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cite este trabalho como:</div><div id="ref-frosi2025" class="csl-entry quarto-appendix-citeas">
Frosi, Gustavo. 2025. <span>“Trabalhos - XV Reunião Sul Brasileira de
Ciência do Solo.”</span> January 5. <a href="https://doi.org/10.59350/97z3m-yvf13">https://doi.org/10.59350/97z3m-yvf13</a>.
</div></div></section></div> ]]></description>
  <category>R</category>
  <category>Solos</category>
  <guid>https://gustavofrosi.com.br/recap/2025-01-05-RSBCS-2024/</guid>
  <pubDate>Sun, 05 Jan 2025 03:00:00 GMT</pubDate>
  <media:content url="https://gustavofrosi.com.br/recap/2025-01-05-RSBCS-2024/logo.png" medium="image" type="image/png" height="45" width="144"/>
</item>
<item>
  <title>Do caos ao conhecimento:  use \(y = \beta_{0} + \beta_{1}x + \epsilon\) para explicar seus experimentos</title>
  <dc:creator>Gustavo Frosi</dc:creator>
  <link>https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/</link>
  <description><![CDATA[ 






<section id="aprendi-assim" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Aprendi assim!</h1>
<p><span style="color: #53868B;"><strong>“Os dados foram analisados por meio da análise de variância e, quando significativo, foram realizadas comparações de médias por Tukey para dados categóricos e regressão para dados quantitativos”</strong></span></p>
<p>Essa é a lógica que eu aprendi durante minha graduação e que se manteve até pelo menos meu mestrado. E não é uma lógica errada, longe disso, mas é muito limitada e responde uma parte dos problemas.</p>
<p>Essa abordagem me transmitia a ideia, ou a sensação, de que era somente dessa forma que os estudos eram realizados. É claro que essa era uma limitação minha ao perceber dessa maneira, mas tenho conduzido algumas pesquisas que me indicam que há um coletivo de pessoas que também pensam assim (isso fica para outro momento).</p>
<p>Neste texto, mostro como a regressão linear pode ser aplicada a dados de natureza contínua e/ou categórica. Além disso, inclui um <a href="regressao_linear.r">tutorial</a> para a implementação em R.</p>
</section>
<section id="a-regressão" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> A regressão</h1>
<p>Francis Galton foi quem desenvolveu o conceito de regressão por volta de 1885. A regressão é utilizada para verificar a relação entre duas ou mais variáveis, de modo que uma delas pode ser descrita, explicada ou predita pelas demais.</p>
<p>A variável que será explicada (<img src="https://latex.codecogs.com/png.latex?y">) é chamada de variável dependente, enquanto a variável que a explica (<img src="https://latex.codecogs.com/png.latex?x">) é denominada variável independente. Isso não significa necessariamente que há uma relação de causa e efeito entre <img src="https://latex.codecogs.com/png.latex?x"> e <img src="https://latex.codecogs.com/png.latex?y">, mas para a análise, considera-se essa dependência entre as variáveis.</p>
<p>Para o <img src="https://latex.codecogs.com/png.latex?y"> em uma regressão linear, é necessário que tenhamos dados do tipo contínuo. No entanto, para o <img src="https://latex.codecogs.com/png.latex?x">, podemos utilizar tanto dados contínuos quanto categóricos.</p>
<p>Uma regressão linear simples pode ser descrita pela equação:</p>
<p><img src="https://latex.codecogs.com/png.latex?y=%5Cbeta_%7B0%7D+%5Cbeta_%7B1%7Dx+%5Cepsilon"> Onde, <img src="https://latex.codecogs.com/png.latex?y"> é a variável dependente; <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B0%7D"> é o intercepto do modelo (ponto que corta o eixo <img src="https://latex.codecogs.com/png.latex?y">); <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B1%7D"> é o coeficiente angular; <img src="https://latex.codecogs.com/png.latex?x"> é a variável independente e <img src="https://latex.codecogs.com/png.latex?%5Cepsilon"> é o erro do modelo (Figura&nbsp;1).</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-reg" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-reg-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/index_files/figure-html/fig-reg-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-reg-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;1: Esquema de representação da regressão linear simples
</figcaption>
</figure>
</div>
</div>
</div>
<section id="como-ela-se-ajusta" class="level2" data-number="2.1">
<h2 data-number="2.1" class="anchored" data-anchor-id="como-ela-se-ajusta"><span class="header-section-number">2.1</span> Como ela se ajusta?</h2>
<p>Para encontrar a curva com o melhor ajuste, é utilizado o método dos mínimos quadrados. Isso significa que o método “encontra” qual das curvas retorna o menor valor para a soma dos quadrados. Essa soma dos quadrados é obtida calculando a diferença entre o valor observado e o valor predito, elevando essa diferença ao quadrado e, somando tudo.</p>
<p>Em outras palavras, esse método encontra “a curva que fica mais próxima dos dados observados”. É claro que a quantidade de matemática e estatística por trás de todo esse método é brutal. Aqui apresento apenas uma explicação superficial.</p>
<p>A Figura&nbsp;2 mostra uma curva (<img src="https://latex.codecogs.com/png.latex?a">) com inclinação zero, que representa o intercepto na média dos valores de <img src="https://latex.codecogs.com/png.latex?y">. Já em <img src="https://latex.codecogs.com/png.latex?b">, temos o melhor ajuste possível para uma regressão linear. A primeira curva pode ser considerada um palpite inicial para explicar os dados, ou seja, utilizando o valor da média. A segunda é um avanço, onde <img src="https://latex.codecogs.com/png.latex?y"> passa a assumir valores dependendo de <img src="https://latex.codecogs.com/png.latex?x">.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-reg2" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-reg2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/index_files/figure-html/fig-reg2-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-reg2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;2: Ajsute de curva para média de y (a) e ajsute de menor erro (b)
</figcaption>
</figure>
</div>
</div>
</div>
<p>A animação abaixo mostra a reta de regressão assumindo diversos valores para <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B0%7D"> e <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B1%7D">. É importante observar que ela começa com uma reta na média de <img src="https://latex.codecogs.com/png.latex?y"> e evolui até alcançar retas para além da mais adequada. Os valores da soma dos quadrados indicam que há uma inclinação que minimiza esse valor, enquanto inclinações anteriores ou posteriores fazem com que a soma dos quadrados aumente.</p>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/index_files/figure-html/unnamed-chunk-4-1.gif" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="variável-categórica-na-regressão" class="level2" data-number="2.2">
<h2 data-number="2.2" class="anchored" data-anchor-id="variável-categórica-na-regressão"><span class="header-section-number">2.2</span> Variável categórica na regressão</h2>
<p>Essa é a parte que mais me chama atenção.</p>
<p>Para que uma variável categórica entre na análise de regressão, ela passa por uma pequena transformação, tornando-se uma <strong>variável dummy</strong>.</p>
<p>Por definição, uma variável dummy assume apenas os valores <img src="https://latex.codecogs.com/png.latex?0"> ou <img src="https://latex.codecogs.com/png.latex?1">, indicando a presença ou ausência de uma categoria. O número de variáveis dummy criadas é sempre igual a <img src="https://latex.codecogs.com/png.latex?n-1">, onde <img src="https://latex.codecogs.com/png.latex?n"> é o número de categorias da variável.</p>
<p>Se tivermos <img src="https://latex.codecogs.com/png.latex?3"> grupos em nossa variável, então teremos <img src="https://latex.codecogs.com/png.latex?2"> variáveis dummy, como mostrado na Tabela&nbsp;1. Nota-se que um dos grupos sempre terá o valor <img src="https://latex.codecogs.com/png.latex?0"> em ambas as dummies, pois serve como referência, e os demais grupos serão comparados a ele. Na Tabela&nbsp;1, o grupo “A” é a referência inicial, mas para as demais comparações, é possível alterar o grupo de referência.</p>
<div class="cell">
<div id="tbl-dummy" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-dummy-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Tabela&nbsp;1: Representação das variáveis dummy
</figcaption>
<div aria-describedby="tbl-dummy-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<table class="cell caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">Grupo</th>
<th style="text-align: right;">Dummy (D1)</th>
<th style="text-align: right;">Dummy (D2)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">A (ref)</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: left;">B</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
</tr>
</tbody>
</table>
</div>
</div>
</figure>
</div>
</div>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-1-contents" aria-controls="callout-1" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Nota</span>Dummy em programas estatísticos
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-1" class="callout-1-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>A criação das variáveis dummy é totalmente automatizada nos programas estatísticos. Logo, você não precisa criá-las manualmente. No entanto, como exercicio, vale a pena rodar uma regressão criando as próprias dummies e ver que o resultado é exatamente o mesmo que o do computador.</p>
</div>
</div>
</div>
<p>A equação de regressão geral pode ser descrita conforme Equação&nbsp;1. Também podemos fazer uma equação para cada grupo (Equação&nbsp;2, Equação&nbsp;3 e Equação&nbsp;4).</p>
<p><span id="eq-dummy"><img src="https://latex.codecogs.com/png.latex?y=%5Cbeta_%7B0%7D+%5Cbeta_%7B1%7DD1+%5Cbeta_%7B2%7DD2+%5Cepsilon_%7Bi%7D%20%5Ctag%7B1%7D"></span></p>
<p>Equação grupo <strong>A</strong>:</p>
<p><span id="eq-dois"><img src="https://latex.codecogs.com/png.latex?y=%5Cbeta_%7B0%7D+%5Cepsilon_%7Bi%7D%20%5Ctag%7B2%7D"></span></p>
<p>Equação grupo <strong>B</strong>:</p>
<p><span id="eq-tres"><img src="https://latex.codecogs.com/png.latex?y=%5Cbeta_%7B0%7D+%5Cbeta_%7B1%7DD1+%5Cepsilon%20%5Ctag%7B3%7D"></span></p>
<p>Equação grupo <strong>C</strong>:</p>
<p><span id="eq-quatro"><img src="https://latex.codecogs.com/png.latex?y=%5Cbeta_%7B0%7D+%5Cbeta_%7B2%7DD2+%5Cepsilon%20%5Ctag%7B4%7D"></span></p>
<p>Agora, repare como a Equação&nbsp;2 é descrita apenas pelo intercepto, pois a variável de grupo assume o valor <img src="https://latex.codecogs.com/png.latex?0"> em todas as dummies (Tabela&nbsp;1). Já para os demais grupos aparece na equaçao as dummies em que o valor <img src="https://latex.codecogs.com/png.latex?1"> é atribuído.</p>
<p>A interpretação de uma regressão com variáveis dummy é, basicamente, a diferença de média entre os grupos (semelhante a um teste de Tukey). Na Figura&nbsp;3, podemos ver as médias dos grupos A, B e C e os respectivos <img src="https://latex.codecogs.com/png.latex?%5Cbeta">s, que indicam a diferença entre elas. Essa diferença pode ser entendida como uma diferença angular, pois, se as médias são diferentes, forma-se um ângulo (<img src="https://latex.codecogs.com/png.latex?%5Cneq%200">) entre as médias.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-dummy" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-dummy-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/index_files/figure-html/fig-dummy-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-dummy-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;3: Representação esquemática da regressão com variável dummy
</figcaption>
</figure>
</div>
</div>
</div>
</section>
<section id="requisitosindicadores-de-qualidade-para-a-regressão-linear" class="level2" data-number="2.3">
<h2 data-number="2.3" class="anchored" data-anchor-id="requisitosindicadores-de-qualidade-para-a-regressão-linear"><span class="header-section-number">2.3</span> Requisitos/indicadores de qualidade para a regressão linear</h2>
<p>Como um professor disse uma vez:</p>
<blockquote class="blockquote">
<p>O grande perigo é a pessoa apenas saber fazer uma regressão.</p>
</blockquote>
<p>Essa frase é uma crítica às pessoas que apenas sabem montar um modelo e sair interpretando. Uma interpretação útil surge de uma regressão bem feita, e, para isso, é necessário conhecer a qualidade do modelo gerado. Abaixo estão os principais critérios para avaliar como seu modelo se comporta.</p>
<section id="as-observações-devem-ser-independentes" class="level3" data-number="2.3.1">
<h3 data-number="2.3.1" class="anchored" data-anchor-id="as-observações-devem-ser-independentes"><span class="header-section-number">2.3.1</span> As observações devem ser independentes</h3>
<p>Esse requisito diz que o valor de uma observação não pode ter influência no valor de outra observação.</p>
</section>
<section id="as-variáveis-preditivas-não-devem-possuir-alta-correlação" class="level3" data-number="2.3.2">
<h3 data-number="2.3.2" class="anchored" data-anchor-id="as-variáveis-preditivas-não-devem-possuir-alta-correlação"><span class="header-section-number">2.3.2</span> As variáveis preditivas não devem possuir alta correlação</h3>
<p>Também chamada de multicolinearidade, a alta correlação entre as variáveis independentes é um aspecto importante a ser considerado. Variáveis com alta correlação podem causar diversos problemas, como distorção dos resultados e interpretações espúrias.</p>
</section>
<section id="homocedasticidade-e-normalidade-dos-resíduos" class="level3" data-number="2.3.3">
<h3 data-number="2.3.3" class="anchored" data-anchor-id="homocedasticidade-e-normalidade-dos-resíduos"><span class="header-section-number">2.3.3</span> Homocedasticidade e normalidade dos resíduos</h3>
<p>A homocedasticidade é semelhante à homogeneidade de variâncias testada na ANOVA. No entanto, a homocedasticidade diz respeito à variância dos erros do modelo (<img src="https://latex.codecogs.com/png.latex?%5Cepsilon">), que deve ser constante em toda a escala ou nos níveis da variável <img src="https://latex.codecogs.com/png.latex?x">.</p>
<p>Já a normalidade diz respeito aos erros do modelo, que devem ser aproximadamente normais.</p>
</section>
</section>
</section>
<section id="exemplo-de-regressão" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Exemplo de regressão</h1>
<p>Agora, vamos fazer um exemplo de regressão com variáveis contínuas e discretas no mesmo modelo. Depois vamos interpretar cada variável e verificar a qualidade do modelo.</p>
<p>Para o exemplo vamos considerar 2 variáveis dependentes que são 5 doses de algum fertilizante e outra como 3 cultivares de qualquer planta. Já a variável dependete será a produtividade dessa planta (Tabela&nbsp;2).</p>
<p>Nossa pergunta será: “<strong>As variáveis dose e cultivar são preditores da produtividade da cultura?</strong>”.</p>
<div class="cell">
<div id="tbl-media" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-media-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Tabela&nbsp;2: Banco de dados inventado para a análise
</figcaption>
<div aria-describedby="tbl-media-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<div class="datatables html-widget html-fill-item" id="htmlwidget-d96970b9501c191ad406" style="width:100%;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-d96970b9501c191ad406">{"x":{"filter":"none","vertical":false,"extensions":["Buttons"],"data":[["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132","133","134","135","136","137","138","139","140","141","142","143","144","145","146","147","148","149","150"],["Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar1","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar2","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3","Cultivar3"],[0,0,0,0,0,0,0,0,0,0,50,50,50,50,50,50,50,50,50,50,100,100,100,100,100,100,100,100,100,100,150,150,150,150,150,150,150,150,150,150,200,200,200,200,200,200,200,200,200,200,0,0,0,0,0,0,0,0,0,0,50,50,50,50,50,50,50,50,50,50,100,100,100,100,100,100,100,100,100,100,150,150,150,150,150,150,150,150,150,150,200,200,200,200,200,200,200,200,200,200,0,0,0,0,0,0,0,0,0,0,50,50,50,50,50,50,50,50,50,50,100,100,100,100,100,100,100,100,100,100,150,150,150,150,150,150,150,150,150,150,200,200,200,200,200,200,200,200,200,200],[47.19762176723894,48.8491125525836,57.79354157074562,50.35254195712288,50.64643867580473,58.57532493441641,52.30458102994601,43.67469382696733,46.56573574053237,47.77169014950021,61.12040898719731,56.79906913528682,57.00385725297026,55.5534135797256,52.22079432622962,63.93456568401539,57.4892523911462,45.16691421685181,58.50677950781843,52.63604296136033,54.66088147006577,58.91012542670853,54.8699777584638,56.3555438535443,56.87480366075371,51.56653344628793,64.18893522247262,60.76686558918258,54.30931531494026,66.26907460534963,67.13232110738407,63.52464258503864,69.47562830522511,69.39066743766521,69.10790540818743,68.44320127050045,67.76958826768795,64.69044144711638,63.47018668130042,63.09764499493809,66.52646510539743,68.96041360990201,63.67301824215868,80.84477982669256,76.03980999152495,64.38445708398325,67.98557582350462,67.66672323188391,73.89982559168159,69.58315466764085,46.26659256997377,44.85726622325649,44.78564771354342,51.84301142007229,43.87114507170367,52.5823530221477,37.25623597884889,47.92306874818035,45.61927121922307,46.07970784371987,51.89819741379941,47.48838273445349,48.3339630816529,44.90712308446456,44.64104386762211,51.51764320702129,52.24104889314713,50.26502113365252,54.61133733939869,60.25042342813572,52.54484416971732,43.45415562179593,60.02869262231128,51.45399618708804,51.55995691766321,60.1278568484835,53.57613496474495,48.89641143872732,55.90651739874575,54.30554318780478,60.02882092949943,61.92640200563165,58.14669984103795,63.22188274259416,58.89756719090624,61.65890981957848,65.48419506574673,62.17590745416901,58.37034207234387,65.74403809225547,69.9675192798106,67.74198479754035,66.1936586755572,61.86046961980314,71.80326224265004,61.99870206426436,75.93666496508288,72.66305313092595,63.82149820449762,59.8678954984661,36.44796718150349,41.28441854578265,38.76654060768813,38.26228700301134,35.24190716367492,39.7748613759554,36.07547765271462,31.66029031705932,38.09886739856119,44.59498304530383,42.12326518695804,48.03982161112517,36.91058645855418,44.7221901723773,47.59703601971731,46.50576681083357,45.52838097074471,41.79646995847312,40.75147826983209,39.87935604697543,50.58823298550063,45.26262692907599,47.54721278149666,48.71953903900877,59.21931002616104,46.74025049152271,51.17693286142428,50.38980424781855,45.19071682934936,49.64345956938201,62.22275429211675,57.25752026539607,55.2061646099647,52.88751583830187,44.73376389229742,60.65668606707088,47.69679964537589,58.69973755438667,64.54551784608742,47.780534195141,63.50892167687356,58.68901255298766,52.13927920427256,52.42666173109124,51.99231913212704,57.34546738914848,52.6912220750205,63.43958386487914,70.50054470262836,53.56484761982411]],"container":"<table class=\"display\">\n  <thead>\n    <tr>\n      <th> <\/th>\n      <th>Cultivar<\/th>\n      <th>Dose<\/th>\n      <th>Produtividade<\/th>\n    <\/tr>\n  <\/thead>\n<\/table>","options":{"dom":"Bfrtip","buttons":[{"extend":"copy","title":"tabela_inventada"},{"extend":"csv","title":"tabela_inventada"},{"extend":"excel","title":"tabela_inventada"}],"columnDefs":[{"className":"dt-right","targets":[2,3]},{"orderable":false,"targets":0},{"name":" ","targets":0},{"name":"Cultivar","targets":1},{"name":"Dose","targets":2},{"name":"Produtividade","targets":3}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
</figure>
</div>
</div>
<section id="especificando-o-modelo" class="level2" data-number="3.1">
<h2 data-number="3.1" class="anchored" data-anchor-id="especificando-o-modelo"><span class="header-section-number">3.1</span> Especificando o modelo</h2>
<p>Nosso modelo teórico e sem interação pode ser representado como:</p>
<p><img src="https://latex.codecogs.com/png.latex?y=%20%5Cbeta_0%20+%20%5Cbeta_1*dose%20+%20%5Cbeta_2*cultivar%20+%20%5Cepsilon"></p>
</section>
<section id="resultado" class="level2" data-number="3.2">
<h2 data-number="3.2" class="anchored" data-anchor-id="resultado"><span class="header-section-number">3.2</span> Resultado</h2>
<p>A Tabela&nbsp;3 mostra os resultados da regressão. Na tabela, a primeira coluna representa o intercepto ou a variável <img src="https://latex.codecogs.com/png.latex?x">. A coluna “Beta” apresenta os coeficientes ajustados, seguida pelo intervalo de confiança para o coeficiente e, por fim, o valor de <em>p</em>.</p>
<div class="cell">
<div id="tbl-regressao" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-regressao-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Tabela&nbsp;3: Resultado da regressão linear
</figcaption>
<div aria-describedby="tbl-regressao-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<div id="zjqzqzuguz" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#zjqzqzuguz table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#zjqzqzuguz thead, #zjqzqzuguz tbody, #zjqzqzuguz tfoot, #zjqzqzuguz tr, #zjqzqzuguz td, #zjqzqzuguz th {
  border-style: none;
}

#zjqzqzuguz p {
  margin: 0;
  padding: 0;
}

#zjqzqzuguz .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#zjqzqzuguz .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#zjqzqzuguz .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#zjqzqzuguz .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#zjqzqzuguz .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#zjqzqzuguz .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#zjqzqzuguz .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#zjqzqzuguz .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#zjqzqzuguz .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#zjqzqzuguz .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#zjqzqzuguz .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#zjqzqzuguz .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#zjqzqzuguz .gt_spanner_row {
  border-bottom-style: hidden;
}

#zjqzqzuguz .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#zjqzqzuguz .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#zjqzqzuguz .gt_from_md > :first-child {
  margin-top: 0;
}

#zjqzqzuguz .gt_from_md > :last-child {
  margin-bottom: 0;
}

#zjqzqzuguz .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#zjqzqzuguz .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#zjqzqzuguz .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#zjqzqzuguz .gt_row_group_first td {
  border-top-width: 2px;
}

#zjqzqzuguz .gt_row_group_first th {
  border-top-width: 2px;
}

#zjqzqzuguz .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#zjqzqzuguz .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#zjqzqzuguz .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#zjqzqzuguz .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#zjqzqzuguz .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#zjqzqzuguz .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#zjqzqzuguz .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#zjqzqzuguz .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#zjqzqzuguz .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#zjqzqzuguz .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#zjqzqzuguz .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#zjqzqzuguz .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#zjqzqzuguz .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#zjqzqzuguz .gt_left {
  text-align: left;
}

#zjqzqzuguz .gt_center {
  text-align: center;
}

#zjqzqzuguz .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#zjqzqzuguz .gt_font_normal {
  font-weight: normal;
}

#zjqzqzuguz .gt_font_bold {
  font-weight: bold;
}

#zjqzqzuguz .gt_font_italic {
  font-style: italic;
}

#zjqzqzuguz .gt_super {
  font-size: 65%;
}

#zjqzqzuguz .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#zjqzqzuguz .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#zjqzqzuguz .gt_indent_1 {
  text-indent: 5px;
}

#zjqzqzuguz .gt_indent_2 {
  text-indent: 10px;
}

#zjqzqzuguz .gt_indent_3 {
  text-indent: 15px;
}

#zjqzqzuguz .gt_indent_4 {
  text-indent: 20px;
}

#zjqzqzuguz .gt_indent_5 {
  text-indent: 25px;
}

#zjqzqzuguz .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#zjqzqzuguz div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table cell caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="gt_col_headings header">
<th id="label" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col"><strong>Characteristic</strong></th>
<th id="estimate" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Beta</strong></th>
<th id="conf.low" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>95% CI</strong></th>
<th id="p.value" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>p-value</strong></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="label">(Intercept)</td>
<td class="gt_row gt_center" headers="estimate">49.9</td>
<td class="gt_row gt_center" headers="conf.low">48.2, 51.6</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">Cultivar</td>
<td class="gt_row gt_center" headers="estimate"><br>
</td>
<td class="gt_row gt_center" headers="conf.low"><br>
</td>
<td class="gt_row gt_center" headers="p.value"><br>
</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;Cultivar1</td>
<td class="gt_row gt_center" headers="estimate">—</td>
<td class="gt_row gt_center" headers="conf.low">—</td>
<td class="gt_row gt_center" headers="p.value"><br>
</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;Cultivar2</td>
<td class="gt_row gt_center" headers="estimate">-4.44</td>
<td class="gt_row gt_center" headers="conf.low">-6.30, -2.58</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;Cultivar3</td>
<td class="gt_row gt_center" headers="estimate">-11.4</td>
<td class="gt_row gt_center" headers="conf.low">-13.3, -9.58</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">Dose</td>
<td class="gt_row gt_center" headers="estimate">0.103</td>
<td class="gt_row gt_center" headers="conf.low">0.092, 0.113</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3">No. Obs.</td>
<td class="gt_row gt_center" headers="estimate" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3">150</td>
<td class="gt_row gt_center" headers="conf.low" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3"><br>
</td>
<td class="gt_row gt_center" headers="p.value" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3"><br>
</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">R²</td>
<td class="gt_row gt_center" headers="estimate">0.775</td>
<td class="gt_row gt_center" headers="conf.low"><br>
</td>
<td class="gt_row gt_center" headers="p.value"><br>
</td>
</tr>
</tbody><tfoot>
<tr class="gt_sourcenotes odd">
<td colspan="4" class="gt_sourcenote">Abbreviation: CI = Confidence Interval</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
</figure>
</div>
</div>
</section>
<section id="sec-interpretacao" class="level2" data-number="3.3">
<h2 data-number="3.3" class="anchored" data-anchor-id="sec-interpretacao"><span class="header-section-number">3.3</span> Interpretação</h2>
<p>O modelo criado (Tabela&nbsp;4) tem um <img src="https://latex.codecogs.com/png.latex?R%5E2"> de <img src="https://latex.codecogs.com/png.latex?0,77">, o que é considerado um valor “bom”. Todas as variáveis <img src="https://latex.codecogs.com/png.latex?x"> foram significativas (<img src="https://latex.codecogs.com/png.latex?p%3C0,05">). A interpretação de cada variável é:</p>
<p><strong>Cultivar:</strong> A Cultivar2 tem uma produtividade em média de <strong>4,44</strong> unidades a <strong>menos</strong> que a Cultivar1. Já a Cultivar3 tem produtividade média de <strong>11,4</strong> unidades a <strong>menos</strong> que a Cultivar1. Alterando a referência para a Cultivar2, observa-se que a Cultivar3 tem produtividade média de <strong>7</strong> unidades a <strong>menos</strong> que a Cultivar2</p>
<p><strong>Dose:</strong> Com relação a dose, a cada aumento de uma unidade temos um <strong>aumento</strong> na produtividade de <strong>0,103</strong> unidades.</p>
<div class="cell">
<div id="tbl-regressaocultivares" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-regressaocultivares-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Tabela&nbsp;4: Resultado da regressão linear entre Dose e Cultivar para prever produtividade. “Refe Cultivar1” são os resultados utilizando a categória “Cultivar1” como referência, já “Refe Cultivar2” é utilizada a “Cultivar2”
</figcaption>
<div aria-describedby="tbl-regressaocultivares-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<div id="wflsxwdxcn" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#wflsxwdxcn table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#wflsxwdxcn thead, #wflsxwdxcn tbody, #wflsxwdxcn tfoot, #wflsxwdxcn tr, #wflsxwdxcn td, #wflsxwdxcn th {
  border-style: none;
}

#wflsxwdxcn p {
  margin: 0;
  padding: 0;
}

#wflsxwdxcn .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#wflsxwdxcn .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#wflsxwdxcn .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#wflsxwdxcn .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#wflsxwdxcn .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#wflsxwdxcn .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#wflsxwdxcn .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#wflsxwdxcn .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#wflsxwdxcn .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#wflsxwdxcn .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#wflsxwdxcn .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#wflsxwdxcn .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#wflsxwdxcn .gt_spanner_row {
  border-bottom-style: hidden;
}

#wflsxwdxcn .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#wflsxwdxcn .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#wflsxwdxcn .gt_from_md > :first-child {
  margin-top: 0;
}

#wflsxwdxcn .gt_from_md > :last-child {
  margin-bottom: 0;
}

#wflsxwdxcn .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#wflsxwdxcn .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#wflsxwdxcn .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#wflsxwdxcn .gt_row_group_first td {
  border-top-width: 2px;
}

#wflsxwdxcn .gt_row_group_first th {
  border-top-width: 2px;
}

#wflsxwdxcn .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#wflsxwdxcn .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#wflsxwdxcn .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#wflsxwdxcn .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#wflsxwdxcn .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#wflsxwdxcn .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#wflsxwdxcn .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#wflsxwdxcn .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#wflsxwdxcn .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#wflsxwdxcn .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#wflsxwdxcn .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#wflsxwdxcn .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#wflsxwdxcn .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#wflsxwdxcn .gt_left {
  text-align: left;
}

#wflsxwdxcn .gt_center {
  text-align: center;
}

#wflsxwdxcn .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#wflsxwdxcn .gt_font_normal {
  font-weight: normal;
}

#wflsxwdxcn .gt_font_bold {
  font-weight: bold;
}

#wflsxwdxcn .gt_font_italic {
  font-style: italic;
}

#wflsxwdxcn .gt_super {
  font-size: 65%;
}

#wflsxwdxcn .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#wflsxwdxcn .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#wflsxwdxcn .gt_indent_1 {
  text-indent: 5px;
}

#wflsxwdxcn .gt_indent_2 {
  text-indent: 10px;
}

#wflsxwdxcn .gt_indent_3 {
  text-indent: 15px;
}

#wflsxwdxcn .gt_indent_4 {
  text-indent: 20px;
}

#wflsxwdxcn .gt_indent_5 {
  text-indent: 25px;
}

#wflsxwdxcn .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#wflsxwdxcn div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table cell caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<colgroup>
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
</colgroup>
<thead>
<tr class="gt_col_headings gt_spanner_row header">
<th rowspan="2" id="label" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col"><strong>Characteristic</strong></th>
<th colspan="3" id="level 1; estimate_1" class="gt_center gt_columns_top_border gt_column_spanner_outer" data-quarto-table-cell-role="th" scope="colgroup"><div class="gt_column_spanner">
<strong>Refe Cultivar1</strong>
</div></th>
<th colspan="3" id="level 1; estimate_2" class="gt_center gt_columns_top_border gt_column_spanner_outer" data-quarto-table-cell-role="th" scope="colgroup"><div class="gt_column_spanner">
<strong>Refe Cultivar2</strong>
</div></th>
</tr>
<tr class="gt_col_headings even">
<th id="estimate_1" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Beta</strong></th>
<th id="conf.low_1" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>95% CI</strong></th>
<th id="p.value_1" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>p-value</strong></th>
<th id="estimate_2" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Beta</strong></th>
<th id="conf.low_2" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>95% CI</strong></th>
<th id="p.value_2" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>p-value</strong></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="label">(Intercept)</td>
<td class="gt_row gt_center" headers="estimate_1">49.9</td>
<td class="gt_row gt_center" headers="conf.low_1">48.2, 51.6</td>
<td class="gt_row gt_center" headers="p.value_1">&lt;0.001</td>
<td class="gt_row gt_center" headers="estimate_2">45.5</td>
<td class="gt_row gt_center" headers="conf.low_2">43.8, 47.2</td>
<td class="gt_row gt_center" headers="p.value_2">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">Cultivar</td>
<td class="gt_row gt_center" headers="estimate_1"><br>
</td>
<td class="gt_row gt_center" headers="conf.low_1"><br>
</td>
<td class="gt_row gt_center" headers="p.value_1"><br>
</td>
<td class="gt_row gt_center" headers="estimate_2"><br>
</td>
<td class="gt_row gt_center" headers="conf.low_2"><br>
</td>
<td class="gt_row gt_center" headers="p.value_2"><br>
</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;Cultivar1</td>
<td class="gt_row gt_center" headers="estimate_1">—</td>
<td class="gt_row gt_center" headers="conf.low_1">—</td>
<td class="gt_row gt_center" headers="p.value_1"><br>
</td>
<td class="gt_row gt_center" headers="estimate_2">4.44</td>
<td class="gt_row gt_center" headers="conf.low_2">2.58, 6.30</td>
<td class="gt_row gt_center" headers="p.value_2">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;Cultivar2</td>
<td class="gt_row gt_center" headers="estimate_1">-4.44</td>
<td class="gt_row gt_center" headers="conf.low_1">-6.30, -2.58</td>
<td class="gt_row gt_center" headers="p.value_1">&lt;0.001</td>
<td class="gt_row gt_center" headers="estimate_2">—</td>
<td class="gt_row gt_center" headers="conf.low_2">—</td>
<td class="gt_row gt_center" headers="p.value_2"><br>
</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;Cultivar3</td>
<td class="gt_row gt_center" headers="estimate_1">-11.4</td>
<td class="gt_row gt_center" headers="conf.low_1">-13.3, -9.58</td>
<td class="gt_row gt_center" headers="p.value_1">&lt;0.001</td>
<td class="gt_row gt_center" headers="estimate_2">-7.00</td>
<td class="gt_row gt_center" headers="conf.low_2">-8.87, -5.14</td>
<td class="gt_row gt_center" headers="p.value_2">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">Dose</td>
<td class="gt_row gt_center" headers="estimate_1">0.103</td>
<td class="gt_row gt_center" headers="conf.low_1">0.092, 0.113</td>
<td class="gt_row gt_center" headers="p.value_1">&lt;0.001</td>
<td class="gt_row gt_center" headers="estimate_2">0.103</td>
<td class="gt_row gt_center" headers="conf.low_2">0.092, 0.113</td>
<td class="gt_row gt_center" headers="p.value_2">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3">No. Obs.</td>
<td class="gt_row gt_center" headers="estimate_1" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3">150</td>
<td class="gt_row gt_center" headers="conf.low_1" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3"><br>
</td>
<td class="gt_row gt_center" headers="p.value_1" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3"><br>
</td>
<td class="gt_row gt_center" headers="estimate_2" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3"><br>
</td>
<td class="gt_row gt_center" headers="conf.low_2" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3"><br>
</td>
<td class="gt_row gt_center" headers="p.value_2" style="border-top-width: 2px; border-top-style: solid; border-top-color: #D3D3D3"><br>
</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">R²</td>
<td class="gt_row gt_center" headers="estimate_1">0.775</td>
<td class="gt_row gt_center" headers="conf.low_1"><br>
</td>
<td class="gt_row gt_center" headers="p.value_1"><br>
</td>
<td class="gt_row gt_center" headers="estimate_2"><br>
</td>
<td class="gt_row gt_center" headers="conf.low_2"><br>
</td>
<td class="gt_row gt_center" headers="p.value_2"><br>
</td>
</tr>
</tbody><tfoot>
<tr class="gt_sourcenotes odd">
<td colspan="7" class="gt_sourcenote">Abbreviation: CI = Confidence Interval</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
</figure>
</div>
</div>
</section>
<section id="sec-qualidade" class="level2" data-number="3.4">
<h2 data-number="3.4" class="anchored" data-anchor-id="sec-qualidade"><span class="header-section-number">3.4</span> Indicadores de qualidade</h2>
<section id="outliers" class="level3" data-number="3.4.1">
<h3 data-number="3.4.1" class="anchored" data-anchor-id="outliers"><span class="header-section-number">3.4.1</span> Outliers</h3>
<p>Na regressão linear, uma das maneiras de verificar se há dados influentes para o modelo é por meio da distância de Cook. Existem diferentes interpretações em relação aos valores de corte para considerar um valor influente. Aqui, utilizo o valor de <img src="https://latex.codecogs.com/png.latex?1"> como ponto de corte. Há discussões sobre o uso de valores limite para diagnósticos, mas, de qualquer forma, utilizar o limite de <img src="https://latex.codecogs.com/png.latex?1"> já é melhor que não fazer uma avaliação de outliers.</p>
<p>Podemos observar na Figura&nbsp;4 que nenhum ponto se aproxima do valor de <img src="https://latex.codecogs.com/png.latex?1">, portanto, aparentemente, não temos pontos discrepantes que possam prejudicar o modelo.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-cook" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-cook-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/index_files/figure-html/fig-cook-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-cook-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;4: Distância de cook para o modelo de regressão
</figcaption>
</figure>
</div>
</div>
</div>
</section>
<section id="normalidade-dos-resíduos-e-homocedasticidade" class="level3" data-number="3.4.2">
<h3 data-number="3.4.2" class="anchored" data-anchor-id="normalidade-dos-resíduos-e-homocedasticidade"><span class="header-section-number">3.4.2</span> Normalidade dos resíduos e homocedasticidade</h3>
<p>A Figura&nbsp;5 mostra o QQ-plot dos resíduos. O ideal é que os pontos estejam dispostos perfeitamente em cima da reta, mas isso é praticamente impossível nas análises do dia a dia. Portanto, quanto mais próximos da linha, melhor. Não temos um ponto de corte ou métrica de qualidade específicos para o QQ-plot. Buscamos o melhor ajuste possível, dados os dados que temos.</p>
<p>Verificamos que há alguns desvios em relação à linha, mas, no geral, o resultado é satisfatório. Com isso, podemos concluir que os resíduos são aproximadamente normais. Além disso, tudo indica que não temos problemas com a homocedasticidade.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-normalidade" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-normalidade-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/index_files/figure-html/fig-normalidade-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-normalidade-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;5: QQ-plot dos resíduos do modelo
</figcaption>
</figure>
</div>
</div>
</div>
</section>
<section id="multicolinearidade" class="level3" data-number="3.4.3">
<h3 data-number="3.4.3" class="anchored" data-anchor-id="multicolinearidade"><span class="header-section-number">3.4.3</span> Multicolinearidade</h3>
<p>A tolerância entre as variáveis foi de <img src="https://latex.codecogs.com/png.latex?1"> (Tabela&nbsp;5) o que significa uma boa tolerância. Em geral, acima de <img src="https://latex.codecogs.com/png.latex?0,80"> já temos variáveis que se toleram no modelo.</p>
<div class="cell">
<div id="tbl-vif" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-vif-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Tabela&nbsp;5: Tolerância entre as variáveis do modelo
</figcaption>
<div aria-describedby="tbl-vif-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<table class="cell caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">Term</th>
<th style="text-align: right;">VIF</th>
<th style="text-align: right;">Tolerance</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Cultivar</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="even">
<td style="text-align: left;">Dose</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
</tr>
</tbody>
</table>
</div>
</div>
</figure>
</div>
</div>
<p>O teste de Durbin-Watson é utilizado para verificar a autocorrelação entre os resíduos da regressão. O valor ideal desse teste é <img src="https://latex.codecogs.com/png.latex?2">, o que indica a ausência de autocorrelação. Se o valor for maior ou menor que <img src="https://latex.codecogs.com/png.latex?2">, há indícios de autocorrelação positiva ou negativa, respectivamente.</p>
<p>A análise do Durbin-Watson (Tabela&nbsp;6) mostra um valor de <img src="https://latex.codecogs.com/png.latex?2,08">, ou seja, é aproximadamente <img src="https://latex.codecogs.com/png.latex?2"> e indica que não temos autocorrelação.</p>
<div class="cell">
<div id="tbl-durbin" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-durbin-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Tabela&nbsp;6: QQ-plot dos resíduos do modelo
</figcaption>
<div aria-describedby="tbl-durbin-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<table class="cell caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: right;">z</th>
<th style="text-align: right;">p</th>
<th style="text-align: left;">Method</th>
<th style="text-align: left;">Alternative</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">2.08806</td>
<td style="text-align: right;">0.61766</td>
<td style="text-align: left;">Durbin-Watson test</td>
<td style="text-align: left;">true autocorrelation is greater than 0</td>
</tr>
</tbody>
</table>
</div>
</div>
</figure>
</div>
</div>
</section>
</section>
<section id="representação-gráfica-do-modelo" class="level2" data-number="3.5">
<h2 data-number="3.5" class="anchored" data-anchor-id="representação-gráfica-do-modelo"><span class="header-section-number">3.5</span> Representação gráfica do modelo</h2>
<p>Na Seção&nbsp;3.3 vimos quais foram os efeitos significativos do modelo, já na Seção&nbsp;3.4 observamos que o modelo está adequado e explica bem os dados. Agora, criamos uma visualização gráfica para apresentar melhor os resultados. Poderia ter sido feito um gráfico com as médias dos grupos de cultivares, mostrando o intervalo de confiança e uma regressão com as doses, mas preferi representar dessa forma.</p>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/index_files/figure-html/unnamed-chunk-7-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</section>
</section>
<section id="regressão-vs-anova" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Regressão vs ANOVA</h1>
<p>Parece que essa frase gera um conflito dentro da agronomia. Aparenta que usamos as técnicas para coisas totalmente diferentes, mas no final das contas uma ANOVA é um caso particular da regressão linear. Todos os resultados obtidos em um teste de ANOVA serão encontrado em um modelo de regressão linear.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-2-contents" aria-controls="callout-2" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Nota</span>Resultado da ANOVA
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-2" class="callout-2-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>Realizando uma ANOVA para comparação</p>
<p>Tabela anova</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code>             Df Sum Sq Mean Sq F value Pr(&gt;F)    
Cultivar      2   3327    1664   74.77 &lt;2e-16 ***
Dose          1   7889    7889  354.55 &lt;2e-16 ***
Residuals   146   3249      22                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
</div>
</div>
<p>Normalidade</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code># A tibble: 1 × 3
  variable      statistic     p
  &lt;chr&gt;             &lt;dbl&gt; &lt;dbl&gt;
1 Produtividade     0.991 0.482</code></pre>
</div>
</div>
<p>Homogeneidade</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code># A tibble: 1 × 4
    df1   df2 statistic     p
  &lt;int&gt; &lt;int&gt;     &lt;dbl&gt; &lt;dbl&gt;
1     2   147    0.0904 0.914</code></pre>
</div>
</div>
<p>Comparações por tukey</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code> Cultivar  emmean    SE  df lower.CL upper.CL .group
 Cultivar3   48.7 0.667 146     47.4     50.0  a    
 Cultivar2   55.7 0.667 146     54.4     57.1   b   
 Cultivar1   60.2 0.667 146     58.9     61.5    c  

Confidence level used: 0.95 
P value adjustment: tukey method for comparing a family of 3 estimates 
significance level used: alpha = 0.05 
NOTE: If two or more means share the same grouping symbol,
      then we cannot show them to be different.
      But we also did not show them to be the same. </code></pre>
</div>
</div>
<p>Regressão das doses</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code>
Call:
lm(formula = Produtividade ~ Dose, data = dados)

Residuals:
     Min       1Q   Median       3Q      Max 
-15.2724  -4.7458   0.1992   4.6481  15.7107 

Coefficients:
             Estimate Std. Error t value Pr(&gt;|t|)    
(Intercept) 44.622242   0.942674   47.34   &lt;2e-16 ***
Dose         0.102559   0.007697   13.32   &lt;2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 6.666 on 148 degrees of freedom
Multiple R-squared:  0.5454,    Adjusted R-squared:  0.5423 
F-statistic: 177.5 on 1 and 148 DF,  p-value: &lt; 2.2e-16</code></pre>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="referências" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Referências</h1>
<p><a href="https://galton.org/essays/1880-1889/galton-1886-jaigi-regression-stature.pdf">Galton, F.S. Regression Towards Mediocrity in Hereditary Stature. The Journal of the Anthropological Institute of Great Britain and Ireland, 15, 246.</a></p>
<p><a href="https://web.williams.edu/Mathematics/sjmiller/public_html/105Sp10/handouts/MethodLeastSquares.pdf">Miller, S. J. (2006). The method of least squares. Mathematics Department Brown University, 8(1), 5-11.</a></p>
<p><a href="'">Field, A., Miles, J., &amp; Field, Z. (2012). Discovering statistics using R. SAGE Publications.</a></p>
<p><a href="https://doi.org/10.1038/s41433-022-01949-z">Bzovsky, S., Phillips, M.R., Guymer, R.H. et al.&nbsp;The clinician’s guide to interpreting a regression analysis. Eye 36, 1715–1717 (2022).</a></p>
<p><a href="https://wires.onlinelibrary.wiley.com/doi/abs/10.1002/wics.1198?casa_token=dBGX5Xe2CBgAAAAA%3A_H6oh6Ib_EjYxUhAAGlOsGOYDLVG8-Mr3_wBLFYWYBtB3Zbr-pltrMPkBKoDTn4GfL_ekrYJixXDag">Su, X., Yan, X., &amp; Tsai, C.-L. (2012). Linear regression. Wiley Interdisciplinary Reviews: Computational Statistics, 4(3), 275–294.</a></p>
<p><a href="https://doi.org/10.1007/978-981-97-3385-9_7">Okoye, K., Hosseini, S. (2024). Regression Analysis in R: Linear Regression and Logistic Regression. In: R Programming. Springer, Singapore.</a></p>


</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> De volta ao topo</a><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citação</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{frosi2024,
  author = {Frosi, Gustavo},
  title = {Do caos ao conhecimento: \textless br\textgreater{} use \$y =
    \textbackslash beta\_\{0\} + \textbackslash beta\_\{1\}x +
    \textbackslash epsilon\$ para explicar seus experimentos},
  date = {2024-08-22},
  url = {https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/},
  doi = {10.59350/3h6hb-49h88},
  langid = {pt}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cite este trabalho como:</div><div id="ref-frosi2024" class="csl-entry quarto-appendix-citeas">
Frosi, Gustavo. 2024. <span>“Do caos ao conhecimento: &lt;br&gt; use $y
= \beta_{0} + \beta_{1}x + \epsilon$ para explicar seus
experimentos.”</span> August 22. <a href="https://doi.org/10.59350/3h6hb-49h88">https://doi.org/10.59350/3h6hb-49h88</a>.
</div></div></section></div> ]]></description>
  <category>R</category>
  <category>Regressão Linear</category>
  <category>Estatística</category>
  <guid>https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/</guid>
  <pubDate>Thu, 22 Aug 2024 03:00:00 GMT</pubDate>
  <media:content url="https://gustavofrosi.com.br/recap/2024-08-21-regressao-linear/ima_fundo.jpeg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Quantos artigos eu preciso ter no currículo até o fim do doutorado em Ciência do Solo?</title>
  <dc:creator>Gustavo Frosi</dc:creator>
  <link>https://gustavofrosi.com.br/recap/2024-04-09-artigos-doutorandos/</link>
  <description><![CDATA[ 





<section id="introdução" class="level1">
<h1>Introdução</h1>
<p>A resposta é óbvia: Não sei!</p>
<p>E não tem como saber, pois, vai depender de perguntas que vão para além do individual de cada um. Agora, não significa que não podemos fazer algumas comparações e tentar sair do escuro. Bem, é exatamente isso que eu trago nesse texto. Não são raros os dias que penso que tudo que faço (da Pós-graduação) leva milhões de anos para ficar pronto e, por consequência, me vejo divagando em uma estrada de pensamentos que não tem fim. Para acalmar minhas expectativas, eu resolvi fazer algo. Gastei parte do meu tempo para tentar encontrar parte da resposta. Assim, investiguei, mesmo que superficialmente, a pergunta: Qual o desempenho dos estudantes de doutorado que já passaram pela pós? Com a esperança de encontrar algo para verificar como está o meu andamento individual. O desempenho é difícil de mensurar e, bem, o que o desempenho realmente mede, né? Mas utilizei o que tinha em meu alcance para traçar uma linha de raciocínio. A informação mais fácil de conseguir de alunos já doutores é o número de artigos que publicaram e que estão no currículo Lattes. Com base nesses números levantei algumas hipóteses: 1. Artigos demandam tempo e o número de publicações reflete o tempo investido. 2. A quantidade de artigos pode indicar as parcerias do aluno. 3. Quanto mais artigos, mais a pessoa se dedica a temas relacionados à pós-graduação. Obviamente, há problemas com essas hipóteses e elas abordam apenas uma parte do problema, mas são as que tenho até o momento. Ainda assim, a necessidade de publicar artigos por parte dos alunos torna essa uma opção interessante a ser considerada.</p>
<section id="metodologia" class="level2">
<h2 class="anchored" data-anchor-id="metodologia">Metodologia</h2>
<p>Para minha análise, coletei dados de diversas fontes. A análise foi conduzida exclusivamente com alunos de doutorado que frequentaram o curso de Ciência do Solo entre os anos de 2013 e 2022. O período foi determinado de forma arbitrária, com base no tempo disponível para realizar o trabalho. Como sou aluno da UFRGS, utilizei os dados dos egressos do Programa de Pós-Graduação em Ciência do Solo desta universidade. No entanto, para aumentar a amostra, incluí também dados da pós-graduação em Ciência do Solo da UFSM.</p>
<p>Nos sites de cada programa de pós-graduação (Egressos da UFRGS e Egressos do PPGCS da UFSM), compilei o número e os nomes dos alunos formados em cada um dos anos especificados. Inicialmente, fiquei surpreso ao descobrir que o PPGCS da UFSM possui um levantamento sobre a atuação profissional de seus egressos. Essa é exatamente mais uma das ideias que gostaria de implementar com os alunos do PPGCS da UFRGS, já que desconheço tal informação.</p>
<p>Com os nomes em mãos, iniciei a tarefa mais trabalhosa de todo o processo: encontrar e baixar o currículo Lattes de cada um deles. Ao todo, foram baixados 86 currículos da UFRGS e 98 da UFSM.</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>Os dados podem ser baixados no meu github <a href="https://github.com/FGu5tav0/artigos_doutorado_solos">link</a></p>
</div>
</div>
<p>Outra informação importante era determinar os anos em que cada pessoa cursou o doutorado em seus respectivos programas de pós-graduação. Para isso, obtive a base de dados de discentes da CAPES, que abrange o período de 2004 a 2022. Utilizei o currículo Lattes como filtro para identificar os alunos que concluíram o doutorado em cada um dos programas e os anos em que estiveram matriculados.</p>
<p>A maior dificuldade agora é definir quais artigos cada pessoa publicou durante o doutorado. Inicialmente, não há como fazer essa distinção, pois essa informação não está disponível no Lattes e não posso me dar ao luxo de investir mais tempo nessa investigação. Portanto, estabeleci um critério de corte: considerei apenas os artigos com ano de publicação igual ou anterior ao ano de conclusão do doutorado. Reconheço que, na prática, a maioria dos artigos é publicada no ano seguinte à submissão, e que os alunos tendem a publicar os artigos do doutorado mais próximo do final do curso, o que poderia resultar em anos diferentes. No entanto, essa foi a abordagem que encontrei para manter todos os dados em uma mesma “base”. É importante ressaltar que estamos partindo do zero em termos de informação. Com os resultados obtidos, realizei uma análise descritiva dos dados por meio de histogramas. Além disso, elaborei um gráfico da frequência total de artigos publicados e conduzi uma análise dos títulos dos artigos por meio de uma nuvem de palavras, levando em consideração as palavras mais frequentes encontradas nos artigos. Por fim, realizei uma análise da frequência com que termos como nitrogênio, fósforo e potássio aparecem nos títulos, como uma forma indireta de compreender a tendência ou determinar qual é considerado mais importante.</p>
</section>
<section id="resultados" class="level2">
<h2 class="anchored" data-anchor-id="resultados">Resultados</h2>
<p>Dos 184 alunos da amostra, um total de 1517 artigos foram encontrados, porém 4 dos alunos não tinham nenhum artigo em seus currículos Lattes. Isso suscita uma discussão inicial sobre a importância do Lattes e a necessidade de mantê-lo atualizado. O Lattes é um exemplo mundial de uma plataforma bem-sucedida que armazena dados de pesquisadores e alunos. Apesar de suas falhas, é inegável seu valor como um repositório de acesso público. De fato, o Lattes é a fonte de dados para várias pesquisas interessantes. O histograma (Figura 1) mostra que a distribuição de artigos publicados com ano igual ou inferior ao ano de conclusão do doutorado é assimétrica negativa ou se aproxima disso. Com um número maior de pessoas publicando números pequenos de artigos frente a números mais altos.</p>
<p><img src="https://gustavofrosi.com.br/recap/2024-04-09-artigos-doutorandos/ima/hist.jpeg" class="img-fluid"> Figura 1: Histograma da distribuição do número de artigos por aluno.</p>
<div class="callout callout-style-default callout-warning 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">
Aviso
</div>
</div>
<div class="callout-body-container callout-body">
<p>um modelo de massa de probabilidade será ajustado no futuro</p>
</div>
</div>
<p>A Figura 2 apresenta os dados expressos em termos de frequência (absoluta e acumulada). O número médio de artigos foi de 8; no entanto, devido à natureza assimétrica da curva, a média pode não representar adequadamente os dados. Portanto, a mediana, com um valor de 6 artigos, pode ser mais relevante. Isso revela uma descoberta significativa: o número mais frequente corresponde à própria mediana. Além disso, mais de 50% dos alunos no banco de dados publicaram entre 2 e 8 artigos. A avaliação se isso é muito ou pouco depende de vários aspectos. Outro dado interessante é que 90% dos alunos tiveram entre 0 e 18 artigos. No entanto, ao observar o gráfico, é evidente que números elevados são raros. Espero que esta breve análise auxilie meus colegas de mestrado e doutorado em Ciência do Solo a refletirem sobre sua produção acadêmica.</p>
<p><img src="https://gustavofrosi.com.br/recap/2024-04-09-artigos-doutorandos/ima/freq.jpeg" class="img-fluid"> Figura 2: Frequência relativa e acumuada do número de artigos por aluno de doutorado.</p>
<section id="análise-dos-títulos" class="level3">
<h3 class="anchored" data-anchor-id="análise-dos-títulos">Análise dos títulos</h3>
<p>Com os títulos, temos a nuvem de palavras. Essa visualização mostra as palavras mais frequentes nos títulos dos mais de mil artigos avaliados. Como esperado, ‘Solo’ e ‘Brasil’ são as palavras mais comuns. Em seguida, encontramos palavras como ‘produtividade’, ‘diferentes’, ‘nitrogênio’, ‘fósforo’ e assim por diante. Acredito que uma mensagem interessante aqui seja tentar evitar palavras óbvias. Embora seja desafiador, aumentar a diversidade nos títulos é uma prática enriquecedora.</p>
<center>
<iframe src="ima/total.html" width="750" height="650">
</iframe>
</center>
</section>
<section id="análise-de-n-p-e-k-em-títulos" class="level3">
<h3 class="anchored" data-anchor-id="análise-de-n-p-e-k-em-títulos">Análise de N, P e K em títulos</h3>
<p>Bem, como estou realizando meu doutorado com potássio, achei interessante verificar a frequência com que ele é mencionado nos títulos dos artigos. Surpreendentemente, ele é pouco mencionado. A Figura 3 mostra uma visualização do número de vezes que N, P e K aparecem nos títulos, tanto em português quanto em inglês. É interessante notar a disparidade significativa entre os elementos. Não sei se isso está relacionado à importância, à dificuldade de pesquisa ou a algum outro fator que possa explicar essa diferença. Acredito que ainda não tenhamos descoberto tudo o que podemos sobre nenhum desses elementos.</p>
<p><img src="https://gustavofrosi.com.br/recap/2024-04-09-artigos-doutorandos/ima/npk.jpeg" class="img-fluid"> Figura 2: Número de vezes que N, P e K foram encontrados nos títulos dos artigos.</p>
</section>
</section>
<section id="conclusão" class="level2">
<h2 class="anchored" data-anchor-id="conclusão">Conclusão</h2>
<p>Para concluir, determinar o número ideal de artigos é uma tarefa complexa, e esta análise está longe de fornecer uma resposta definitiva. No entanto, é inegável que os dados coletados oferecem informações importantes. Espero que essas descobertas incentivem meus colegas a refletirem sobre suas próprias jornadas acadêmicas. Questões como essa são fascinantes de investigar, e caso surjam dúvidas ou alguém queira contribuir, não hesite em enviar uma mensagem.</p>


</section>
</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> De volta ao topo</a><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citação</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{frosi2024,
  author = {Frosi, Gustavo},
  title = {Quantos artigos eu preciso ter no currículo até o fim do
    doutorado em Ciência do Solo?},
  date = {2024-04-15},
  url = {https://gustavofrosi.com.br/recap/2024-04-09-artigos-doutorandos/},
  doi = {10.59350/bzssr-kxs17},
  langid = {pt}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cite este trabalho como:</div><div id="ref-frosi2024" class="csl-entry quarto-appendix-citeas">
Frosi, Gustavo. 2024. <span>“Quantos artigos eu preciso ter no currículo
até o fim do doutorado em Ciência do Solo?”</span> April 15. <a href="https://doi.org/10.59350/bzssr-kxs17">https://doi.org/10.59350/bzssr-kxs17</a>.
</div></div></section></div> ]]></description>
  <category>R</category>
  <category>Doutorado</category>
  <category>DataViz</category>
  <category>ggplot2</category>
  <guid>https://gustavofrosi.com.br/recap/2024-04-09-artigos-doutorandos/</guid>
  <pubDate>Mon, 15 Apr 2024 03:00:00 GMT</pubDate>
  <media:content url="https://gustavofrosi.com.br/recap/2024-04-09-artigos-doutorandos/aritogos_ima.jpeg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>BananaBudget</title>
  <dc:creator>Gustavo Frosi</dc:creator>
  <dc:creator>Diogo Bolzan</dc:creator>
  <link>https://gustavofrosi.com.br/recap/2024-02-15-BananBudget1/</link>
  <description><![CDATA[ 





<section id="introdução" class="level1">
<h1>Introdução</h1>
<div class="columns">
<div class="column" style="width:70%;">
<p><em>Você já pensou qual seu gasto no mercado? Quais os produtos que mais compra? Qual a frequência que vai ao mercado?</em></p>
<p><em>Eu e o <a href="https://diogovieri.rbind.io/">Diogo</a> já!</em></p>
</div><div class="column" style="width:30%;">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://gustavofrosi.com.br/recap/2024-02-15-BananBudget1/hex.png" class="img-fluid quarto-figure quarto-figure-center figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Neste texto, vamos mostrar como manipulamos notas fiscais de mercado para responder às questões iniciais por meio da programação. Morando em Porto Alegre com mais duas pessoas (totalizando quatro), é fundamental ter um controle de gastos. Após vários meses registrando todos os gastos no mercado, surgiu a seguinte pergunta: “Será que podemos identificar quais produtos compramos com maior ou menor frequência?” <em>(coisa de doido, né?)</em>. De certa forma, já sabíamos que, ao utilizar o CPF nas compras, as notas ficam armazenadas em algum lugar, mas não tínhamos certeza de onde.</p>
<p>No Rio Grande do Sul, assim como em outros estados, existe um sistema de “recompensa” chamado Nota Fiscal Gaúcha. Ao adicionar o CPF nas notas, você concorre a prêmios e outras vantagens. Além disso, é possível acessar todas as notas fiscais, com informações como data, produtos adquiridos, preços e estabelecimentos.</p>
<p>Uma maneira de obter essas notas é por meio de <em>“web scraping”</em>. Para saber mais sobre esse processo, você pode conferir o <a href="https://gustavofrosi.com.br/recap/2024-02-05%20webscraping%20python/">Post</a>, onde descrevemos como realizá-lo.</p>
<p>Com notas na mão (ou no pc) é hora de organizar os dados!</p>
</section>
<section id="extração-de-dados-dos-pdfs" class="level1">
<h1>Extração de dados dos pdfs</h1>
<p>Criamos uma função chamada “pega_produto()”, essa função identifica padrões no texto e separa as informações em um <em>data frame</em>, onde cada linha representa um produto comprado. Ao aplicar essa função em todas as notas, obtemos uma base de dados com os seguintes campos: Data, Hora, Nome do Produto, Preço do Produto… (Figura&nbsp;1)</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Carregando os pacotes</span></span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(pdftools) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># manipulação de pdf</span></span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># conjunto de pacotes para manipulação e visualização</span></span>
<span id="cb1-4"></span>
<span id="cb1-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Primeiro defini o diretório da pasta com as notas.</span></span>
<span id="cb1-6">pasta <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"notas/notas/"</span></span>
<span id="cb1-7"></span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># lista os arquivos dentro da pasta</span></span>
<span id="cb1-9">docs <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;">list.files</span>(pasta, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">full.names =</span> T)</span>
<span id="cb1-10"></span>
<span id="cb1-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># a função 'pega_produto' será responsável por encontrar cada linha da nota com os produtos</span></span>
<span id="cb1-12">pega_produto <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>(pdf) {</span>
<span id="cb1-13">  df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span></span>
<span id="cb1-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pdf_text</span>(pdf) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</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;">"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unlist</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enframe</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"linha"</span>)</span>
<span id="cb1-18"></span>
<span id="cb1-19">  data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(linha, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data de Emissão"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_extract</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><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;">d{2}.</span><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;">d{2}.</span><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;">d{4}.</span><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;">d{2}.</span><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;">d{2}.</span><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;">d{2}"</span>)</span>
<span id="cb1-22"></span>
<span id="cb1-23">  produtos <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(linha, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><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;">S</span><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;">d{4,}"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(linha, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^</span><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;">s{4,}</span><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;">d"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-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;">linha =</span> linha <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> stringr<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;">str_replace_all</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[</span><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;">s]{3,}"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">replacement =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"---"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">separate</span>(</span>
<span id="cb1-28">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> linha, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">into =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb1-29">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ts"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nome"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"quant"</span>,</span>
<span id="cb1-30">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"unidade"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"valor_uni"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"valor_total"</span></span>
<span id="cb1-31">      ),</span>
<span id="cb1-32">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"---"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">convert =</span> F</span>
<span id="cb1-33">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-34">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</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;">1</span>)</span>
<span id="cb1-35"></span>
<span id="cb1-36">  dados_fim <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;">mutate</span>(</span>
<span id="cb1-37">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.data =</span> produtos,</span>
<span id="cb1-38">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(</span>
<span id="cb1-39">      data,</span>
<span id="cb1-40">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(produtos<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>id)</span>
<span id="cb1-41">    )</span>
<span id="cb1-42">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-43">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">separate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">into =</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;">"data"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"hora"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-44">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb1-45">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hora =</span> hora <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_extract</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><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;">d{2}</span><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;">:</span><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;">d{2}</span><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;">:</span><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;">d{2}"</span>),</span>
<span id="cb1-46">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">valor_uni =</span> valor_uni <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> stringr<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;">str_replace_all</span>(</span>
<span id="cb1-47">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[</span><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;">,]"</span>,</span>
<span id="cb1-48">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">replacement =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span></span>
<span id="cb1-49">      ),</span>
<span id="cb1-50">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">valor_total =</span> valor_total <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> stringr<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;">str_replace_all</span>(</span>
<span id="cb1-51">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[</span><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;">,]"</span>,</span>
<span id="cb1-52">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">replacement =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span></span>
<span id="cb1-53">      )</span>
<span id="cb1-54">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-55">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">relocate</span>(data, hora) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-56">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb1-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dmy</span>(data),</span>
<span id="cb1-58">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>(id),</span>
<span id="cb1-59">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">valor_uni =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(valor_uni),</span>
<span id="cb1-60">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">valor_total =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(valor_total)</span>
<span id="cb1-61">    )</span>
<span id="cb1-62"></span>
<span id="cb1-63">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(dados_fim)</span>
<span id="cb1-64">}</span>
<span id="cb1-65"></span>
<span id="cb1-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># criando a base de dados</span></span>
<span id="cb1-67">base <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;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb1-68"></span>
<span id="cb1-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># para utilizar a função pega_produto() em cada nota usamos um loop for e juntamos as linhas com a função bind_rows()</span></span>
<span id="cb1-70"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</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 class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(docs)) {</span>
<span id="cb1-71">  b1 <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;">pega_produto</span>(docs[i])</span>
<span id="cb1-72">  base <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> base <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(b1)</span>
<span id="cb1-73">}</span>
<span id="cb1-74"></span>
<span id="cb1-75"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># aqui visualizamos a base</span></span>
<span id="cb1-76">base <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">glimpse</span>()</span>
<span id="cb1-77"></span>
<span id="cb1-78"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># e por fim salvamos</span></span>
<span id="cb1-79"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">save</span>(base, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">file =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"notas/base.RData"</span>)</span></code></pre></div></div>
</div>
<div id="fig-tabela" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-tabela-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-02-15-BananBudget1/ima/data_base.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-tabela-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;1: base de dados
</figcaption>
</figure>
</div>
</section>
<section id="organização-dos-dados" class="level1">
<h1>Organização dos dados</h1>
<p>Nossa base de dados foi construída com 205 notas fiscais do período de janeiro a dezembro de 2023. Após uma visualização prévia, decidimos criar uma variável relacionada ao tipo de produto, resultando na variável “categoria” (conforme apresentado na <strong>Tabela 1</strong>). O número de categorias foi determinado subjetivamente, com a intenção de discriminar adequadamente os produtos.</p>
<div class="cell">
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">Categoria</th>
<th style="text-align: left;">Item</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Carboidratos</td>
<td style="text-align: left;">Pão, Massas, Arroz…</td>
</tr>
<tr class="even">
<td style="text-align: left;">Doces</td>
<td style="text-align: left;">Chocolate, Sorvete, Bolacha…</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Bebidas</td>
<td style="text-align: left;">Leite, Refrigerante, Água…</td>
</tr>
<tr class="even">
<td style="text-align: left;">Embutidos</td>
<td style="text-align: left;">Queijo, Linguiça Calabresa, Bacon…</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Carnes E Ovos</td>
<td style="text-align: left;">Ovo, Carnes Vermelhas, Peito de Frango…</td>
</tr>
<tr class="even">
<td style="text-align: left;">Higiene</td>
<td style="text-align: left;">Desodorante, Sabonete…</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Frutas</td>
<td style="text-align: left;">Banana, Maça, Uva…</td>
</tr>
<tr class="even">
<td style="text-align: left;">Verduras</td>
<td style="text-align: left;">Tomate, Pepino, Alface…</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Limpeza</td>
<td style="text-align: left;">Amaciante, Detergente…</td>
</tr>
<tr class="even">
<td style="text-align: left;">Temperos E Molhos</td>
<td style="text-align: left;">Massa de Tomate, Salsa, Orégano…</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Tivemos que tomar algumas decisões em relação aos produtos que iríamos incluir na tabela. O primeiro ponto foi determinar que produtos que tivessem apenas uma compra seriam excluídos. Nossa pergunta inicial não visa produtos específicos, mas sim um padrão de consumo geral.</p>
<p>Uma maneira que encontramos para agrupar produtos foi utilizar apenas a primeira palavra do nome do item. No entanto, observamos dois problemas: o primeiro foi a ocorrência de produtos iguais com nomes iniciais diferentes, enquanto o segundo foi a presença de produtos diferentes com nomes iniciais iguais.</p>
<p>Exemplo 1: A palavra <img src="https://latex.codecogs.com/png.latex?%5Ctextbf%7BCHOC%7D"> e <img src="https://latex.codecogs.com/png.latex?%5Ctextbf%7BCHO%7D"> representava o mesmo produto, chocolate.</p>
<p>Exemplo 2: A palavra <img src="https://latex.codecogs.com/png.latex?%5Ctextbf%7BMINI%7D"> era observada no <img src="https://latex.codecogs.com/png.latex?%5Ctextbf%7BMINI%20TOMATE%7D"> e no <img src="https://latex.codecogs.com/png.latex?%5Ctextbf%7BMINI%20PANETONE%7D">.</p>
<p>Esses casos foram tratados de forma manual e caso a caso.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># realizamos uma organização após uma visualização prêvia das categorias </span></span>
<span id="cb2-2">base <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> base <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb2-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb2-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">categoria =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>(cat),</span>
<span id="cb2-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hora =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hms</span>(hora),</span>
<span id="cb2-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mes =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">month</span>(data),</span>
<span id="cb2-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inicial =</span> ini</span>
<span id="cb2-8">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</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;">c</span>(cat, ini)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb2-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mes =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_match</span>(</span>
<span id="cb2-12">      mes,</span>
<span id="cb2-13">      <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 class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"jan"</span>,</span>
<span id="cb2-14">      <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="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fev"</span>,</span>
<span id="cb2-15">      <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> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mar"</span>,</span>
<span id="cb2-16">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span> <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;">"abr"</span>,</span>
<span id="cb2-17">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span> <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;">"mai"</span>,</span>
<span id="cb2-18">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span> <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;">"jun"</span>,</span>
<span id="cb2-19">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span> <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;">"jul"</span>,</span>
<span id="cb2-20">      <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;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ago"</span>,</span>
<span id="cb2-21">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span> <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;">"set"</span>,</span>
<span id="cb2-22">      <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 class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"out"</span>,</span>
<span id="cb2-23">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span> <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;">"nov"</span>,</span>
<span id="cb2-24">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span> <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;">"dez"</span></span>
<span id="cb2-25">    ),</span>
<span id="cb2-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mes =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_title</span>(mes),</span>
<span id="cb2-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">categoria =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_title</span>(categoria),</span>
<span id="cb2-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mes =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(mes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ordered =</span> T, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb2-29">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Jan"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fev"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mar"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Abr"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mai"</span>,</span>
<span id="cb2-30">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Jun"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Jul"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ago"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Set"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Out"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Nov"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dez"</span></span>
<span id="cb2-31">    ))</span>
<span id="cb2-32">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb2-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>( <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># aqui é onde realizamos a junção mencionadas nos exemplos 1 e 2 </span></span>
<span id="cb2-34">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inicial =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb2-35">    inicial <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;">"CHO"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> inicial <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;">"BOMBOM"</span> <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;">"CHOC"</span>,</span>
<span id="cb2-36">    inicial <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;">"SORVETE"</span> <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;">"SORV"</span>,</span>
<span id="cb2-37">    inicial <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;">"BISCOITO"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> inicial <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;">"COOKIE"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> inicial <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;">"CLUB"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> inicial <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;">"BARRA"</span> <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;">"BISC"</span>,</span>
<span id="cb2-38">    inicial <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;">"DOCE"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> inicial <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;">"ECLAIR"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> inicial <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;">"BIBIS"</span> <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;">"BALA"</span>,</span>
<span id="cb2-39">    inicial <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;">"CONFEITO"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> inicial <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;">"MIST"</span> <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;">"BOLO"</span>,</span>
<span id="cb2-40">    inicial <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;">"REFR"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> inicial <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;">"BIPACK"</span> <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;">"REFRIG"</span>,</span>
<span id="cb2-41">    inicial <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;">"VH"</span> <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;">"VHO"</span>,</span>
<span id="cb2-42">    inicial <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;">"MINI"</span> <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;">"TOMATE"</span>,</span>
<span id="cb2-43">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.default =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(inicial)</span>
<span id="cb2-44">  ))</span></code></pre></div></div>
</div>
</section>
<section id="gasto-total-por-categoria" class="level1">
<h1><strong>Gasto total por categoria</strong></h1>
<p>A primeira visualização foi focada em observar o gasto total em cada uma das categorias e o número de compras efetuadas.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># pacotes utilizados em todos os gráficos</span></span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb3-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(showtext)</span>
<span id="cb3-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggtext)</span></code></pre></div></div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">base <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(categoria) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb4-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">valor_total =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(valor_total),</span>
<span id="cb4-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numero =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()</span>
<span id="cb4-6">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-7">  <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;">aes</span>(<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;">fct_reorder</span>(categoria, valor_total), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> valor_total) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-9">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># geom_col(fill = "firebrick") +</span></span>
<span id="cb4-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<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;">"firebrick"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</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;">geom_richtext</span>(</span>
<span id="cb4-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb4-14">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"O nº diz respeito a quantidade &lt;br&gt; de itens comprados"</span>,</span>
<span id="cb4-15">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span></span>
<span id="cb4-16">    ), <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;">4</span>,</span>
<span id="cb4-17">    <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;">"gray70"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label.color =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb4-18">    <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;">"Black Ops One"</span>,</span>
<span id="cb4-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label.padding =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unit</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.30</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.30</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.30</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.30</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lines"</span>),</span>
<span id="cb4-20">  ) <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;">labs</span>(</span>
<span id="cb4-22">    <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;">element_blank</span>(),</span>
<span id="cb4-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Valor total [R$]"</span>,</span>
<span id="cb4-24">    <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;">"Gasto total por categoria"</span>,</span>
<span id="cb4-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> social_caption</span>
<span id="cb4-26">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb4-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping =</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;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nº"</span>, numero)),</span>
<span id="cb4-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nudge_y =</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;">125</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray98"</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;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span></span>
<span id="cb4-30">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-31">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">23</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb4-33">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<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;">"Black Ops One"</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;">20</span>),</span>
<span id="cb4-34">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<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;">"gray90"</span>),</span>
<span id="cb4-35">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_textbox_simple</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;">12</span>)</span>
<span id="cb4-36">  )</span></code></pre></div></div>
</div>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://gustavofrosi.com.br/recap/2024-02-15-BananBudget1/ima/cat_total.jpeg" class="img-fluid figure-img" width="1500"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="gasto-mensal-das-principais-categorias" class="level1">
<h1><strong>Gasto mensal das principais categorias</strong></h1>
<p>O segundo gráfico mostra o gasto mês-a-mês para cada categoria. Para isso utilizamos apenas as 5 maiores categorias em total de gasto.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">gg_bonito <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> base <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;">group_by</span>(categoria, mes) <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;">summarise</span>(</span>
<span id="cb5-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">valor_total =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(valor_total),</span>
<span id="cb5-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numero =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()</span>
<span id="cb5-6">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>categoria <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb5-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temperos E Molhos"</span>,</span>
<span id="cb5-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Limpeza"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Verduras"</span>,</span>
<span id="cb5-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Frutas"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Higiene"</span></span>
<span id="cb5-11">  ))</span>
<span id="cb5-12">gg_bonito2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> gg_bonito <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;">group_by</span>(mes) <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;">mutate</span>(</span>
<span id="cb5-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_mensal =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(valor_total),</span>
<span id="cb5-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">valor_cat =</span> total_mensal <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> valor_total</span>
<span id="cb5-17">  )</span>
<span id="cb5-18"></span>
<span id="cb5-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(gg_bonito) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb5-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> mes,</span>
<span id="cb5-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">node =</span> categoria,</span>
<span id="cb5-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> categoria,</span>
<span id="cb5-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> valor_total</span>
<span id="cb5-25">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_sankey_bump</span>(</span>
<span id="cb5-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">space =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb5-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"alluvial"</span>,</span>
<span id="cb5-29">    <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;">"transparent"</span>,</span>
<span id="cb5-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">smooth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span></span>
<span id="cb5-31">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_viridis_d</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;">"A"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</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;">+</span></span>
<span id="cb5-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_sankey_bump</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_discrete</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;">c</span>(.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">01</span>, .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">001</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-35">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># coord_cartesian(expand = F, clip = "off") +</span></span>
<span id="cb5-36">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb5-37">    <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;">"Despesas mensais em diferentes categorias de alimentos"</span>,</span>
<span id="cb5-38">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Valor Total Mensal [R$]"</span>,</span>
<span id="cb5-39">    <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;">element_blank</span>(),</span>
<span id="cb5-40">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb5-41">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> social_caption</span>
<span id="cb5-42">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-43">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_richtext</span>(</span>
<span id="cb5-44">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb5-45">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Espessura da linha indica o  &lt;span style = 'color:tomato;'&gt;gasto da categoria&lt;/span&gt;. &lt;br&gt; O somatório de todas as espessuras &lt;br&gt; indica o &lt;span style = 'color:tomato;'&gt;valor total mensal&lt;/span&gt;."</span>,</span>
<span id="cb5-46">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">840</span></span>
<span id="cb5-47">    ), <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;">4.4</span>,</span>
<span id="cb5-48">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label.color =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb5-49">    <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;">"Playfair Display"</span>,</span>
<span id="cb5-50">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label.padding =</span> grid<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;">unit</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</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;">4</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pt"</span>)</span>
<span id="cb5-51">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-52">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb5-53">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<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;">"Playfair Display"</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;">20</span>),</span>
<span id="cb5-54">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</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;">35</span>, .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>),</span>
<span id="cb5-55">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<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;">"transparent"</span>),</span>
<span id="cb5-56">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"horizontal"</span>,</span>
<span id="cb5-57">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</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;">15</span>),</span>
<span id="cb5-58">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_textbox_simple</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;">12</span>)</span>
<span id="cb5-59">  )</span></code></pre></div></div>
</div>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://gustavofrosi.com.br/recap/2024-02-15-BananBudget1/ima/cat_ao_tempo.jpeg" class="img-fluid figure-img" width="1500"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="gasto-mensal-e-total-dos-principais-produtos" class="level1">
<h1><strong>Gasto mensal e total dos principais produtos</strong></h1>
<p>Na última análise, consideramos as categorias que registraram o maior número de compras. Para isso, utilizamos as seguintes categorias: carboidratos, doces, bebidas, frutas e verduras. Dentro de cada uma dessas categorias, identificamos os produtos mais frequentemente adquiridos e os representamos em um único gráfico.</p>
<p>É importante mencionar que, embora o tomate seja botanicamente classificado como uma fruta, optamos por incluí-lo na categoria verdura. <em>Colocamos ele na categoria verdura pois comemos na salada e não como sobremesa!</em></p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">dft <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> base <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;">filter</span>(categoria <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</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;">"Carboidratos"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Doces"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Bebidas"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Frutas"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Verduras"</span>)) <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;">filter</span>(inicial <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</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;">"PAO"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CHOC"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"REFRIG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BANANA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOMATE"</span>)) <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;">group_by</span>(mes, categoria, inicial) <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;">summarise</span>(</span>
<span id="cb6-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">valor_total =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(valor_total),</span>
<span id="cb6-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numero =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()</span>
<span id="cb6-8">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb6-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;">inicial =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_match</span>(</span>
<span id="cb6-10">    inicial,</span>
<span id="cb6-11">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BANANA"</span> <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;">"Banana"</span>,</span>
<span id="cb6-12">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CHOC"</span> <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;">"Chocolate"</span>,</span>
<span id="cb6-13">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PAO"</span> <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;">"Pão"</span>,</span>
<span id="cb6-14">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"REFRIG"</span> <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;">"Refrigerante"</span>,</span>
<span id="cb6-15">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOMATE"</span> <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;">"Tomate"</span></span>
<span id="cb6-16">  ))</span>
<span id="cb6-17"></span>
<span id="cb6-18">valor_dez <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dft <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(mes <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;">"Dez"</span>)</span>
<span id="cb6-19"></span>
<span id="cb6-20">tot_maximo <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dft <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb6-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(inicial) <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;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(valor_total))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb6-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb6-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">texto =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb6-25">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sweet Banana"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Cream Cheese Demo"</span>,</span>
<span id="cb6-26">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Bready Alternates Demo"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Loki Cola"</span>,</span>
<span id="cb6-27">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sweet Banana"</span></span>
<span id="cb6-28">    ),</span>
<span id="cb6-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cor =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb6-30">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gold3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"chocolate4"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkgoldenrod3"</span>,</span>
<span id="cb6-31">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"firebrick3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tomato2"</span></span>
<span id="cb6-32">    )</span>
<span id="cb6-33">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb6-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">full_join</span>(valor_dez)</span>
<span id="cb6-35"></span>
<span id="cb6-36">github_icon <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;#xf09b"</span></span>
<span id="cb6-37">git_gf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FGu5tav0"</span></span>
<span id="cb6-38">git_dv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DiogoVBol"</span></span>
<span id="cb6-39"></span>
<span id="cb6-40">social_caption <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> glue<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;">glue</span>(</span>
<span id="cb6-41">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;span style='font-family:</span><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;">Font Awesome 6 Brands</span><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;">;'&gt;{github_icon};&lt;/span&gt;</span></span>
<span id="cb6-42"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  &lt;span style='color: #000000'&gt;{git_gf}&lt;/span&gt; &lt;br&gt; &lt;span style='font-family:</span><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;">Font Awesome 6 Brands</span><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;">;'&gt;{github_icon};&lt;/span&gt;</span></span>
<span id="cb6-43"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  &lt;span style='color: #000000'&gt;{git_dv}&lt;/span&gt;"</span></span>
<span id="cb6-44">)</span>
<span id="cb6-45"></span>
<span id="cb6-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># com facet ---------------------------------------------------------------</span></span>
<span id="cb6-47"></span>
<span id="cb6-48">dft <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb6-49">  <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="cb6-50">  <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> mes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> valor_total, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</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="cb6-51">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>inicial, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</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;">scales =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"free_y"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-52">  <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;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-53">  <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;">mapping =</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;">fill =</span> inicial), <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="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray90"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stroke =</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>
<span id="cb6-54">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb6-55">    <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;">element_blank</span>(),</span>
<span id="cb6-56">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Valor Total [R$]"</span>,</span>
<span id="cb6-57">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb6-58">    <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;">"Valor mensal pago dos produtos </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;">mais consumidos por categoria"</span>,</span>
<span id="cb6-59">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> social_caption</span>
<span id="cb6-60">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-61">  ggfx<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;">with_shadow</span>(</span>
<span id="cb6-62">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb6-63">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> tot_maximo,</span>
<span id="cb6-64">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb6-65">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> inicial,</span>
<span id="cb6-66">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> texto,</span>
<span id="cb6-67">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</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;">y =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>,</span>
<span id="cb6-68">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> cor,</span>
<span id="cb6-69">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.4</span></span>
<span id="cb6-70">      ),</span>
<span id="cb6-71">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nudge_x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.3</span>,</span>
<span id="cb6-72">      <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;">20</span>,</span>
<span id="cb6-73">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lineheight =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb6-74">    ),</span>
<span id="cb6-75">    <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;">"gray70"</span>,</span>
<span id="cb6-76">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sigma =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span></span>
<span id="cb6-77">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-78">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ylim</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-79">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_discrete</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;">mult =</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;">20</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-80">  <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="cb6-81">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb6-82">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> tot_maximo,</span>
<span id="cb6-83">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb6-84">      <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;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R$"</span>, total),</span>
<span id="cb6-85">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> cor,</span>
<span id="cb6-86">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</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;">y =</span> valor_total</span>
<span id="cb6-87">    ),</span>
<span id="cb6-88">    <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;">"Banana"</span>,</span>
<span id="cb6-89">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nudge_x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.3</span>,</span>
<span id="cb6-90">    <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;">10</span>,</span>
<span id="cb6-91">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lineheight =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb6-92">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-93">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_identity</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-94">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb6-95">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gold3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"chocolate4"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkgoldenrod3"</span>,</span>
<span id="cb6-96">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"firebrick3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tomato2"</span></span>
<span id="cb6-97">  )) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-98">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">28</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-99">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb6-100">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb6-101">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<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;">"gray90"</span>),</span>
<span id="cb6-102">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid.minor.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb6-103">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb6-104">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<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;">"Sweet Banana"</span>),</span>
<span id="cb6-105">    <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_line</span>(),</span>
<span id="cb6-106">    <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;">"none"</span>,</span>
<span id="cb6-107">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(</span>
<span id="cb6-108">      <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;">"Brain Melt regular"</span>,</span>
<span id="cb6-109">      <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;">35</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb6-110">    ),</span>
<span id="cb6-111">    <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="at" style="color: #657422;
background-color: null;
font-style: inherit;">t =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">l =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>),</span>
<span id="cb6-112">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_textbox_simple</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;">16</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</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;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">halign =</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;">05</span>)</span>
<span id="cb6-113">  )</span></code></pre></div></div>
</div>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://gustavofrosi.com.br/recap/2024-02-15-BananBudget1/ima/plot_teste.jpeg" class="img-fluid figure-img" width="1500"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="conclusão" class="level1">
<h1><strong>Conclusão</strong></h1>
<p>Nesse texto, demonstramos como é possível obter informações sobre seus gastos pessoais por meio de web scraping, manipulação e visualização de dados utilizando R e Python. As descobertas aqui foram de caráter exploratório, e uma nova análise com cunho estatístico será realizada em um post futuro. Surgem perguntas interessantes, como: Tenho um dia da semana preferido para ir ao mercado? Ou, a frequência de vezes que vou ao mercado pode prever o preço que gasto no mês?</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>Os códigos apresentados foram produzidos sem critérios de qualidade. Melhorias ainda podem ser feitas.</p>
</div>
</div>


</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> De volta ao topo</a><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citação</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{frosi2024,
  author = {Frosi, Gustavo and Bolzan, Diogo},
  title = {BananaBudget},
  date = {2024-02-15},
  url = {https://gustavofrosi.com.br/recap/2024-02-15-BananBudget1/},
  doi = {10.59350/enae7-stj21},
  langid = {pt}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cite este trabalho como:</div><div id="ref-frosi2024" class="csl-entry quarto-appendix-citeas">
Frosi, Gustavo, and Diogo Bolzan. 2024. <span>“BananaBudget.”</span>
February 15. <a href="https://doi.org/10.59350/enae7-stj21">https://doi.org/10.59350/enae7-stj21</a>.
</div></div></section></div> ]]></description>
  <category>R</category>
  <category>DataViz</category>
  <category>ggplot2</category>
  <guid>https://gustavofrosi.com.br/recap/2024-02-15-BananBudget1/</guid>
  <pubDate>Thu, 15 Feb 2024 03:00:00 GMT</pubDate>
  <media:content url="https://gustavofrosi.com.br/recap/2024-02-15-BananBudget1/pao_choco.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Web scraping Nota Fiscal Gaúcha</title>
  <dc:creator>Gustavo Frosi</dc:creator>
  <link>https://gustavofrosi.com.br/recap/2024-02-05-webscraping-python/</link>
  <description><![CDATA[ 





<section id="introdução" class="level1">
<h1>Introdução</h1>
<p>Você já se perguntou quanto gastou no mercado? E quais os itens que mais comprou? Bom, se você disse que não, acho melhor começar a pensar, e se você disse que sim, mas não sabe como fazer para buscar esses dados, eu tenho uma boa notícia!</p>
<p>Neste texto, descrevo como utilizei o Python na criação de um código que automatizou o download das minhas notas fiscais pessoais (NFC: Nota Fiscal de Consumidor). Deixo claro que o código é destinado ao uso pessoal e doméstico. Minha intenção é apenas o controle de gastos financeiros (e outras brincadeiras com dados).</p>
<p>O exemplo que utilizo aqui é para o site Nota Fiscal Gaúcha e serve apenas para quem utiliza o “benefício”. Fica obvio que é necessário colocar o CPF em todas as compras né.</p>
<p>Antes de começar a codificar, é necessário baixar o webdriver, uma ferramenta para testes de automação que oferece uma série de recursos para utilizar o navegador. O webdriver a ser baixado depende do navegador que você utiliza e da versão instalada. No meu caso, vou ensinar com o navegador da Google, o Google Chrome na versão 121.0.6167.140.</p>
<p>Para fazer o download do webdriver, basta acessar o <a href="https://chromedriver.chromium.org/downloads">link</a></p>
<p>Depois de baixado, é necessário colar o webdriver na pasta onde está o executável do Python. No meu caso, como utilizo o Anaconda, colei no diretório do Anaconda, o mesmo onde fica o Python.</p>
<p>Agora sim! Com isso, já é possível começar a escrever códigos.</p>
</section>
<section id="obtenção-de-dados" class="level1">
<h1>Obtenção de dados</h1>
<p>Antes de capturar qualquer nota, preciso saber quais notas tenho interesse. Para isso, fiz uma busca no site da Nota Fiscal Gaúcha, onde filtrei todas as notas do ano de 2023, apenas para o supermercado Carrefour. Assim, uma lista de dados foi apresentada (Figura&nbsp;1), onde informações de datas, estabelecimento e código da nota são expostos. Deve ser realizado o download desse arquivo em formato Excel ou CSV (ou pdf se quiser algo mais hard). Com isso, temos os dados com a chave da NFC para realizar a captura.</p>
<div id="fig-tabela" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-tabela-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-02-05-webscraping-python/tabela.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-tabela-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;1: Planilha com os dados de cada nota fiscal de interesse
</figcaption>
</figure>
</div>
<section id="ajuste-da-chave-de-acesso" class="level2">
<h2 class="anchored" data-anchor-id="ajuste-da-chave-de-acesso">Ajuste da chave de acesso</h2>
<p>Da planilha baixada do site, apenas a coluna que contém a chave de acesso da nota fiscal é relevante. Realizei uma pequena manipulação na planilha, removendo os espaços da coluna da chave de acesso, e a salvei como arquivo CSV.</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>Códigos em R</p>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" 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>(tidyverse)</span>
<span id="cb1-2"></span>
<span id="cb1-3">dados <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> readxl<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;">read_excel</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Nota Fiscal Gaúcha.xlsx"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-4">  janitor<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;">clean_names</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;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">chave =</span> chave_de_acesso <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove_all</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><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;">s"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(chave)</span>
<span id="cb1-7"></span>
<span id="cb1-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> dados, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">file =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"notas/para_auto.csv"</span>)</span></code></pre></div></div>
</div>
</section>
<section id="encontrando-os-pontos-de-clique" class="level2">
<h2 class="anchored" data-anchor-id="encontrando-os-pontos-de-clique">Encontrando os pontos de clique</h2>
<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>Agora serão apenas códigos em python</p>
</div>
</div>
<p>O procedimento que apresento aqui é baseado em um algoritmo que controla o mouse do computador, realizando cliques e movimentos programados. Como é de se esperar, é necessário fornecer as coordenadas para guiar os movimentos. Essa é uma tarefa manual, porém, é realizada apenas uma vez e se aplica a todas as notas (baixei mais de 200 notas).</p>
<p>Utilizei o MouseInfo para identificar os pontos. Após abrir o console do python (melhor fazer pelo console) é só dar os seguintes comandos:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> mouseinfo <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> mouseInfo</span>
<span id="cb2-2"></span>
<span id="cb2-3">mouseInfo()</span></code></pre></div></div>
</div>
<p>O vídeo abaixo demonstra o funcionamento do MouseInfo, exibindo as marcações das coordenadas x e y à medida que o mouse é movido.</p>
<p><video src="clicks-1707185627966.mp4" class="img-fluid" controls=""><a href="clicks-1707185627966.mp4">Video</a></video></p>
<p>Para encontar os ponto certo basta realizar um teste com o MouseInfo aberto. Abra o <a href="https://www.sefaz.rs.gov.br/ASP/AAE_ROOT/NFE/SAT-WEB-NFE-NFC_1.asp?HML=&amp;chaveNFe=">site</a> onde as notas serão baixadas e identifique os pontos onde será necessário realizar os cliques. O atalho <strong>F6</strong> pode ser utilizado no MouseInfo para marcar as pontos x e y. Siga os passo:</p>
<p>1º Passo: Clique em avançar e depois em imprimir Figura&nbsp;2</p>
<div id="fig-prime" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-prime-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-02-05-webscraping-python/passo a passo/primeira.png" id="fig-prime" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-prime-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;2
</figcaption>
</figure>
</div>
<p>2º Passo: Clique em imprimir na parte do pdf Figura&nbsp;3</p>
<div id="fig-seg" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-seg-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-02-05-webscraping-python/passo a passo/segunda.png" id="fig-seg" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-seg-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;3
</figcaption>
</figure>
</div>
<p>3º Passo: Clique em salvar Figura&nbsp;4</p>
<div id="fig-ter" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-ter-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://gustavofrosi.com.br/recap/2024-02-05-webscraping-python/passo a passo/terceira.png" id="fig-ter" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-ter-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figura&nbsp;4
</figcaption>
</figure>
</div>
<p>Por padrão, o Windows salva na pasta de downloads, mas é possível alterar para a pasta desejada. Basta encontrar o ponto de clique e realizar a mudança de destino.</p>
</section>
</section>
<section id="código-para-o-web-scraping" class="level1">
<h1>Código para o Web scraping</h1>
<p>Para o web scraping, eu utilizei basicamente dois pacotes: o PyAutoGUI e o Selenium. O primeiro realiza o controle do mouse e o preenchimento dos campos, enquanto o Selenium cuida de toda a parte de abrir o navegador e entrar nos links.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pyautogui</span>
<span id="cb3-2"></span>
<span id="cb3-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> selenium <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> webdriver</span></code></pre></div></div>
</div>
<p>O próximo bloco de código mostra toda a parte de acesso ao navegador de forma autônoma. Inclui a definição do tamanho da janela, o que é importante, pois o tamanho afeta a disposição dos botões e, consequentemente, o local dos cliques. Por fim, há a parte que abre o navegador e acessa o link da nota fiscal.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1">options <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> webdriver.ChromeOptions()</span>
<span id="cb4-2">navegador <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> webdriver.Chrome(options<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>options)</span>
<span id="cb4-3"></span>
<span id="cb4-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Definindo o tamanho da janela do navegador</span></span>
<span id="cb4-5">navegador.set_window_size(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1280</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">780</span>)</span>
<span id="cb4-6"></span>
<span id="cb4-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Link para baixar</span></span>
<span id="cb4-8">link1 <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://www.sefaz.rs.gov.br/NFE/NFE-NFC.aspx?chaveNFe="</span></span>
<span id="cb4-9"></span>
<span id="cb4-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Abre o navegador com o link fornecido</span></span>
<span id="cb4-11">navegador.get(link1)</span></code></pre></div></div>
</div>
<p>A última parte é onde ocorre o loop, ou seja, a captação nota a nota. Para isso, importei o arquivo “para_auto.csv”. Este arquivo contém a coluna com as chaves das notas fiscais. A coluna “linha” foi separada utilizando a função “split()”, considerando o separador “,”. Em seguida, foi realizada a substituição das aspas duplas com a função “replace()”. Com isso, a chave de acesso estava pronta para ser utilizada.</p>
<p>O novo link foi gerado considerando a primeira parte do link do site mais a parte numérica que contém a chave de acesso. A função “get()” abriu o navegador e, assim, o PyAutoGUI realizou os cliques nas coordenadas definidas.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">with</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">open</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"para_auto.csv"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r"</span>) <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> arquivo:</span>
<span id="cb5-2">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> linha <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> arquivo:</span>
<span id="cb5-3">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Separa a coluna linha pela ","</span></span>
<span id="cb5-4">        chave_nota <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> linha.split(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">','</span>)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb5-5">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Substitui um aspa dupla por nada</span></span>
<span id="cb5-6">        chave_nota <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> chave_nota.replace(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'"'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span>)</span>
<span id="cb5-7">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Cria um link com o site e a chave da nota</span></span>
<span id="cb5-8">        link <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> link1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> chave_nota</span>
<span id="cb5-9">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Abre o navegador com o link novo</span></span>
<span id="cb5-10">        navegador.get(link)</span>
<span id="cb5-11">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># clica no avançar</span></span>
<span id="cb5-12">        pyautogui.click(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">78</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">310</span>, duration<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb5-13">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># clica no 1º imprimir</span></span>
<span id="cb5-14">        pyautogui.click(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1188</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">164</span>, duration<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)    </span>
<span id="cb5-15">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># clica no segundo imprimir</span></span>
<span id="cb5-16">        pyautogui.click(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">676</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">168</span>, duration<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb5-17">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># clica no tipo de pdf</span></span>
<span id="cb5-18">        pyautogui.click(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">676</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">212</span>, duration<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb5-19">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># clica para selecionar o tipo de pdf 2</span></span>
<span id="cb5-20">        pyautogui.click(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">647</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">525</span>, duration<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb5-21">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># clica em imprimir final pdf</span></span>
<span id="cb5-22">        pyautogui.click(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">175</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">395</span>, duration<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb5-23">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Coloca o número da nota como nome do arquivo</span></span>
<span id="cb5-24">        pyautogui.write(chave_nota)</span>
<span id="cb5-25">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Clica em salvar </span></span>
<span id="cb5-26">        pyautogui.click(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">553</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">465</span>, duration<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb5-27">        pyautogui.click(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">767</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">35</span>, duration<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb5-28">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fecha o navegador</span></span>
<span id="cb5-29">    navegador.close()</span></code></pre></div></div>
</div>
<section id="resultado" class="level2">
<h2 class="anchored" data-anchor-id="resultado">Resultado</h2>
<p>O vídeo exibe o “robô” em ação, realizando a impressão e salvando automaticamente cada uma das notas. Na minha análise, as 205 notas que obtive foram processadas em quase 21 minutos, o que equivale a ~6 segundos por nota (Um computador melhor fará em menos tempo). E você, ocupado com diversas tarefas, conseguiria realizar isso de maneira mais rápida? Mesmo ao atingir a nota de número 100 e perceber que ainda falta mais da metade. Se acha que não, a resposta para isso é simples: <strong>programação!</strong></p>
<p><video src="resultado.mp4" class="img-fluid" controls=""><a href="resultado.mp4">Video</a></video></p>
<p>E agora, o que fazer com essas notas? Começar a extrair os dados manualmente? Pagar alguém para fazer? Excluir do computador e dar um ponto final?</p>
<p>A resposta óbvia é sim, dar um ponto final e excluir. No entanto, se ainda assim você deseja extrair informações dos seus dados, eu aconselho a conferir um próximo post (no futuro), no qual explico o que fazer com as notas.</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>Os códigos apresentados foram produzidos sem critérios de qualidade. Melhorias ainda podem ser feitas.</p>
</div>
</div>


</section>
</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> De volta ao topo</a><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citação</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{frosi2024,
  author = {Frosi, Gustavo},
  title = {Web scraping Nota Fiscal Gaúcha},
  date = {2024-02-06},
  url = {https://gustavofrosi.com.br/recap/2024-02-05-webscraping-python/},
  doi = {10.59350/k8z8n-xd886},
  langid = {pt}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cite este trabalho como:</div><div id="ref-frosi2024" class="csl-entry quarto-appendix-citeas">
Frosi, Gustavo. 2024. <span>“Web scraping Nota Fiscal Gaúcha.”</span>
February 6. <a href="https://doi.org/10.59350/k8z8n-xd886">https://doi.org/10.59350/k8z8n-xd886</a>.
</div></div></section></div> ]]></description>
  <category>R</category>
  <category>python</category>
  <category>Web scraping</category>
  <guid>https://gustavofrosi.com.br/recap/2024-02-05-webscraping-python/</guid>
  <pubDate>Tue, 06 Feb 2024 03:00:00 GMT</pubDate>
  <media:content url="https://gustavofrosi.com.br/recap/2024-02-05-webscraping-python/logo.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Trabalhos - XXIII CLACS | XXXVIII CBCS</title>
  <dc:creator>Gustavo Frosi</dc:creator>
  <dc:creator>Dayana Eckert</dc:creator>
  <link>https://gustavofrosi.com.br/recap/2023-12-17-CBCS-2023/</link>
  <description><![CDATA[ 





<section id="introdução" class="level1">
<h1>Introdução</h1>
<p>O Congresso Brasileiro de Ciência do Solo (CBCS) é um evento técnico-científico que ocorre a cada dois anos (anos ímpares). O objetivo deste evento é reunir alunos, professores, pesquisadores e profissionais das áreas afins para a troca de conhecimento e discussão sobre as futuras perspectivas da ciência do solo.</p>
<p>Esse ano o XXXVIII CBCS ocorreu em Florianopolis – SC, concomitante a ele ocorreu o XXIII Congresso Latino-Americado de Ciência do solo (CLACS). O evento em conjunto foi chamado de SOLOS FLORIPA 2023, com organização das sociedades Latino-americana (SLCS) e Brasileira (SBCS) da Ciência do Solo e realização da Empresa de Pesquisa Agropecuária e Extensão Rural de Santa Catarina (Epagri).</p>
<p>Uma das características mais importante do congresso é a possibilidade de os “pesquisadores” apresentarem trabalhos técnico-científicos sobre seus respectivos objetos de estudo. Diante disso, surge a dúvida em saber quais as áreas/subáreas teve as maiores quantidades de trabalhos apresentados e talvez entender o foco das pesquisas em Ciência do Solo na atualidade. Para sanar essa dúvida (pelo menos parcialmente) apresento nesse post uma forma de retirar os dados do site do congresso e realizar uma apresentação gráfica sobre os trabalhos. Para isso utilizo a linguagem de programação R.</p>
<p>Para mais informações acesse o site: <strong>Site fora do ar</strong></p>
</section>
<section id="pacotes" class="level1">
<h1>Pacotes</h1>
<p>Para essa análise vou utilizar os seguintes pacotes do R</p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" 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>(tidyverse)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(pdftools)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(rvest)</span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(httr)</span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(showtext)</span>
<span id="cb1-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggtext)</span></code></pre></div></div>
</details>
</div>
<p>Atualmente, a <strong>SBCS</strong> possui <strong>4</strong> divisões científicas com 16 subdivisões, sendo:</p>
<ul>
<li><ol type="1">
<li>Solo no espaço e no tempo</li>
</ol>
<ul>
<li>1.1. Gênese e Morfologia do Solo</li>
<li>1.2. Levantamento e Classificação do Solo</li>
<li>1.3. Pedometria</li>
<li>1.4. Paleopedologia</li>
</ul></li>
<li><ol start="2" type="1">
<li>Processos e propriedades do solo</li>
</ol>
<ul>
<li>2.1. Biologia do Solo;</li>
<li>2.2. Física do Solo</li>
<li>2.3. Mineralogia do Solo</li>
<li>2.4. Química do Solo</li>
</ul></li>
<li><ol start="3" type="1">
<li>Uso e manejo do solo</li>
</ol>
<ul>
<li>3.1. Fertilidade do Solo e Nutrição de Plantas</li>
<li>3.2. Corretivos e Fertilizantes</li>
<li>3.3. Manejo e Conservação do Solo e da Água</li>
<li>3.4. Planejamento do Uso da Terra</li>
<li>3.5. Poluição, Remediação do Solo e Recuperação de Áreas Degradadas</li>
</ul></li>
<li>4.Solos, ambiente e sociedade
<ul>
<li>4.1. Educação em Solos e Percepção Pública do Solo</li>
<li>4.2. Solos e Segurança Alimentar</li>
<li>4.3. História, Epistemiologia e Sociologia da Ciência do Solo</li>
</ul></li>
</ul>
<section id="dados" class="level2">
<h2 class="anchored" data-anchor-id="dados">Dados</h2>
<p>Os dados do número de trabalhos está na página de <strong>Trabalho Aprovados</strong> no site. A captura dos dados foi realizada com o endereço eletrônico da página. Um avaliação prévia de como se conportava a página e como os dados aparaciam foi realizada.</p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">primeira_parte <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"https://solosfloripa2023.com.br/evento/solos2023/trabalhosaprovados?titulo=&amp;autor=&amp;t1area_id="</span></span>
<span id="cb2-2"></span>
<span id="cb2-3">id <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;">2</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;">8</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;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>)</span>
<span id="cb2-4"></span>
<span id="cb2-5">segunda_parte <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;modeloformaapresentacaofinal_id=&amp;btBuscar=Buscar"</span></span></code></pre></div></div>
</details>
</div>
<p>Um loop foi realizado para remover os dados de cada uma das áreas e subareas.</p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">df <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;">as.data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</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 class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(id))</span>
<span id="cb3-2"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</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 class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>) {</span>
<span id="cb3-3">  dados <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> httr<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;">GET</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(primeira_parte, id[i], segunda_parte))</span>
<span id="cb3-4">  get_content <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> httr<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;">content</span>(dados)</span>
<span id="cb3-5"></span>
<span id="cb3-6">  raw_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> get_content <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-7">    rvest<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;">html_nodes</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".container-fluid"</span>)</span>
<span id="cb3-8"></span>
<span id="cb3-9">  df[i, ] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span></span>
<span id="cb3-10">    raw_table[[<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;">|&gt;</span></span>
<span id="cb3-11">    rvest<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;">html_text</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</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;">"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unlist</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enframe</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"linha"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-15">    dplyr<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;">filter</span>(stringr<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;">str_detect</span>(linha, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".*registro"</span>))</span>
<span id="cb3-16">}</span></code></pre></div></div>
</details>
</div>
<p>Além de captar as iformações, foi realizado um processamento e manipulação para organizar os dados.</p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">divi <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_table[[<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;">|&gt;</span></span>
<span id="cb4-2">  rvest<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;">html_text</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</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;">"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unlist</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enframe</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"linha"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-6">  dplyr<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;">filter</span>(stringr<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;">str_detect</span>(linha, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" TODASDivisã"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Di"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">simplify =</span> T) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_longer</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cols =</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;">17</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Divi"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nome"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Divi <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;">"V1"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-11">  <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;">di =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Di"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Divi =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(di, nome, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>))</span>
<span id="cb4-13"></span>
<span id="cb4-14"></span>
<span id="cb4-15">d_final <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;">cbind</span>(divi, df)</span>
<span id="cb4-16"></span>
<span id="cb4-17">dados.ok <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> d_final <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">partici =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_extract</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">1:length(id)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb4-20">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[:digit:]{1,}"</span></span>
<span id="cb4-21">    ),</span>
<span id="cb4-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">partici =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(partici)</span>
<span id="cb4-23">  ) </span>
<span id="cb4-24"></span>
<span id="cb4-25"></span>
<span id="cb4-26">comi <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;">str_split</span>(d_final<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Divi, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>)</span>
<span id="cb4-27">data_separado <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;">data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">do.call</span>(rbind, comi))</span>
<span id="cb4-28"></span>
<span id="cb4-29">df_ok <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;">cbind</span>(data_separado, dados.ok)</span>
<span id="cb4-30"></span>
<span id="cb4-31">df_ok <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df_ok <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <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;">remover =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sub</span>(df_ok<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>X2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">end =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span>))</span>
<span id="cb4-32"></span>
<span id="cb4-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">font_add</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Didot"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GFS_Didot/GFSDidot-Regular.ttf"</span>)</span>
<span id="cb4-34"></span>
<span id="cb4-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">showtext_auto</span>()</span></code></pre></div></div>
</details>
</div>
</section>
</section>
<section id="resultados" class="level1">
<h1>Resultados</h1>
<p>Com os dados devidamente organizados foi realizado a visualização gráfica.</p>
<section id="trabalhos-dentro-de-cada-divisão" class="level2">
<h2 class="anchored" data-anchor-id="trabalhos-dentro-de-cada-divisão">Trabalhos dentro de cada divisão</h2>
<div class="tabset-margin-container"></div><div class="panel-tabset">
<ul class="nav nav-tabs"><li class="nav-item"><a class="nav-link active" id="tabset-1-1-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-1" aria-controls="tabset-1-1" aria-selected="true" href="">Divisão 1</a></li><li class="nav-item"><a class="nav-link" id="tabset-1-2-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-2" aria-controls="tabset-1-2" aria-selected="false" href="">Divisão 2</a></li><li class="nav-item"><a class="nav-link" id="tabset-1-3-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-3" aria-controls="tabset-1-3" aria-selected="false" href="">Divisão 3</a></li><li class="nav-item"><a class="nav-link" id="tabset-1-4-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-4" aria-controls="tabset-1-4" aria-selected="false" href="">Divisão 4</a></li></ul>
<div class="tab-content">
<div id="tabset-1-1" class="tab-pane active" aria-labelledby="tabset-1-1-tab">
<p><img src="https://gustavofrosi.com.br/recap/2023-12-17-CBCS-2023/ima_graph/unnamed-chunk-5-1.png" class="img-fluid"></p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">df_ok <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;">filter</span>(X1 <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;">"Divisão 1 – Solo no espaço e no tempo"</span>) <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;">ggplot</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;">y =</span> partici, <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;">fct_reorder</span>(remover, partici))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<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;">"#ef8118"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#bc6a1d"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-6">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># facet_wrap(~X1, scales = "free") +</span></span>
<span id="cb5-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb5-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Nº de trabalhos"</span>,</span>
<span id="cb5-9">    <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;">'Resumos no &lt;span style = "color:#ef8118"&gt; XXIII CLACS | XXXVIII CBCS &lt;/span&gt;'</span>,</span>
<span id="cb5-10">    <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;">"Divisão 1 – Solo no espaço e no tempo"</span></span>
<span id="cb5-11">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</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;">label =</span> partici), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nudge_y =</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="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</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;">5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb5-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<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;">"Didot"</span>),</span>
<span id="cb5-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> ggtext<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;">element_markdown</span>()</span>
<span id="cb5-17">  )</span></code></pre></div></div>
</details>
</div>
</div>
<div id="tabset-1-2" class="tab-pane" aria-labelledby="tabset-1-2-tab">
<p><img src="https://gustavofrosi.com.br/recap/2023-12-17-CBCS-2023/ima_graph/unnamed-chunk-6-1.png" class="img-fluid"></p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">df_ok <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;">filter</span>(X1 <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;">"Divisão 2 – Processos e Propriedades do Solo"</span>) <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;">ggplot</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;">y =</span> partici, <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;">fct_reorder</span>(remover, partici))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<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;">"#ef8118"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#bc6a1d"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-6">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># facet_wrap(~X1, scales = "free") +</span></span>
<span id="cb6-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb6-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Nº de trabalhos"</span>,</span>
<span id="cb6-9">    <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;">'Resumos no &lt;span style = "color:#ef8118"&gt; XXIII CLACS | XXXVIII CBCS &lt;/span&gt;'</span>,</span>
<span id="cb6-10">    <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;">"Divisão 2 – Processos e Propriedades do Solo"</span></span>
<span id="cb6-11">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</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;">label =</span> partici), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nudge_y =</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;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</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;">6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb6-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<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;">"Didot"</span>),</span>
<span id="cb6-16">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_markdown</span>()</span>
<span id="cb6-17">  )</span></code></pre></div></div>
</details>
</div>
</div>
<div id="tabset-1-3" class="tab-pane" aria-labelledby="tabset-1-3-tab">
<p><img src="https://gustavofrosi.com.br/recap/2023-12-17-CBCS-2023/ima_graph/unnamed-chunk-7-1.png" class="img-fluid"></p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">df_ok <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(X1 <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;">"Divisão 3 – Uso e Manejo do Solo"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb7-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;">remover =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(remover, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb7-4">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" Fertilidade do Solo e Nutrição de Plantas"</span>,</span>
<span id="cb7-5">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" Corretivos e Fertilizantes"</span>, </span>
<span id="cb7-6">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" Manejo e Conservação do Solo e da Água"</span>, </span>
<span id="cb7-7">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" Planejamento do Uso da Terra"</span>, </span>
<span id="cb7-8">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" Poluição, Remediação do Solo e Recuperação de Áreas Degradadas"</span></span>
<span id="cb7-9">), <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>
<span id="cb7-10">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fertilidade do Solo e </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;"> Nutrição de Plantas"</span>,</span>
<span id="cb7-11">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Corretivos e Fertilizantes"</span>,</span>
<span id="cb7-12">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Manejo e Conservação </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;"> do Solo e da Água"</span>,</span>
<span id="cb7-13">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Planejamento do Uso da Terra"</span>,</span>
<span id="cb7-14">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Poluição, Remediação do Solo e </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;"> Recuperação de Áreas Degradadas"</span></span>
<span id="cb7-15">))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</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;">y =</span> partici, <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;">fct_reorder</span>(remover, partici))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<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;">"#ef8118"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#bc6a1d"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-19">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># facet_wrap(~X1, scales = "free") +</span></span>
<span id="cb7-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb7-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Nº de trabalhos"</span>,</span>
<span id="cb7-22">    <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;">'Resumos no &lt;span style = "color:#ef8118"&gt; XXIII CLACS | XXXVIII CBCS &lt;/span&gt;'</span>,</span>
<span id="cb7-23">    <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;">"Divisão 3 – Uso e Manejo do Solo"</span></span>
<span id="cb7-24">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</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;">label =</span> partici), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nudge_y =</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;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</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;">6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb7-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<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;">"Didot"</span>),</span>
<span id="cb7-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_markdown</span>()</span>
<span id="cb7-30">  )</span></code></pre></div></div>
</details>
</div>
</div>
<div id="tabset-1-4" class="tab-pane" aria-labelledby="tabset-1-4-tab">
<p><img src="https://gustavofrosi.com.br/recap/2023-12-17-CBCS-2023/ima_graph/unnamed-chunk-8-1.png" class="img-fluid"></p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">df_ok <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;">filter</span>(X1 <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;">"Divisão 4 - Solo, Ambiente e Sociedade"</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;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remover =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(remover, <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>
<span id="cb8-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Educação em Solos e </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;"> Percepção Pública do Solo"</span>,</span>
<span id="cb8-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"História, Epistemologia e </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;"> Sociologia da Ciência"</span>,</span>
<span id="cb8-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Solos e Segurança Alimentar"</span></span>
<span id="cb8-7">  ))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</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;">y =</span> partici, <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;">fct_reorder</span>(remover, partici))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<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;">"#ef8118"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#bc6a1d"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-11">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># facet_wrap(~X1, scales = "free") +</span></span>
<span id="cb8-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb8-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Nº de trabalhos"</span>,</span>
<span id="cb8-14">    <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;">'Resumos no &lt;span style = "color:#ef8118"&gt; XXIII CLACS | XXXVIII CBCS &lt;/span&gt;'</span>,</span>
<span id="cb8-15">    <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;">"Divisão 4 - Solo, Ambiente e Sociedade"</span></span>
<span id="cb8-16">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</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;">label =</span> partici), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nudge_y =</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="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</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;">6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb8-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<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;">"Didot"</span>),</span>
<span id="cb8-21">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_markdown</span>()</span>
<span id="cb8-22">  )</span></code></pre></div></div>
</details>
</div>
</div>
</div>
</div>
</section>
<section id="trabalhos-entre-as-divisões" class="level2">
<h2 class="anchored" data-anchor-id="trabalhos-entre-as-divisões">Trabalhos entre as divisões</h2>
<p>De forma geral, observa-se que a maioria dos trabalhos submetidos e apresentados no evento pertence à divisão científica 3 – Uso e Manejo do Solo, totalizando 829 trabalhos. Em contrapartida, a divisão 4 – Solo, Ambiente e Sociedade apresentou o menor número de trabalhos, com apenas 58.</p>
<p><img src="https://gustavofrosi.com.br/recap/2023-12-17-CBCS-2023/ima_graph/unnamed-chunk-9-1.png" class="img-fluid"></p>
<div class="cell">
<details class="code-fold">
<summary>Código</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">df_ok <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb9-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(X1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb9-3">  <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;">soma =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(partici)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb9-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb9-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">X1 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(X1, <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>
<span id="cb9-6">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Divisão 1 – Solo no </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;"> espaço e no tempo"</span>,</span>
<span id="cb9-7">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Divisão 2 – Processos e </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;">  Propriedades do Solo"</span>,</span>
<span id="cb9-8">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Divisão 3 – Uso e </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;"> Manejo do Solo"</span>,</span>
<span id="cb9-9">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Divisão 4 - Solo, </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;"> Ambiente e Sociedade"</span></span>
<span id="cb9-10">    )),</span>
<span id="cb9-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(soma)</span>
<span id="cb9-12">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb9-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</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;">y =</span> soma, <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;">fct_reorder</span>(X1, soma))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<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;">"#ef8118"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#bc6a1d"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-16">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># facet_wrap(~X1, scales = "free") +</span></span>
<span id="cb9-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb9-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Nº de trabalhos"</span>,</span>
<span id="cb9-19">    <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;">'Resumos no &lt;span style = "color:#ef8118"&gt; XXIII CLACS | XXXVIII CBCS &lt;/span&gt;'</span>,</span>
<span id="cb9-20">    <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;">"Total por divisão"</span></span>
<span id="cb9-21">  ) <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;">geom_text</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;">label =</span> soma), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nudge_y =</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;">32</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</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;">6</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;">theme_minimal</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</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;">theme</span>(</span>
<span id="cb9-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<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;">"Didot"</span>),</span>
<span id="cb9-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_markdown</span>()</span>
<span id="cb9-27">  )</span></code></pre></div></div>
</details>
</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>Os códigos apresentados foram produzidos sem critérios de qualidade. Melhorias ainda podem ser feitas.</p>
</div>
</div>


</section>
</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> De volta ao topo</a><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citação</h2><div><div class="quarto-appendix-secondary-label">BibTeX</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{frosi2023,
  author = {Frosi, Gustavo and Eckert, Dayana},
  title = {Trabalhos - XXIII CLACS \textbar{} XXXVIII CBCS},
  date = {2023-12-17},
  url = {https://gustavofrosi.com.br/recap/2023-12-17-CBCS-2023/},
  doi = {10.59350/k52fq-pv005},
  langid = {pt}
}
</code></pre><div class="quarto-appendix-secondary-label">Por favor, cite este trabalho como:</div><div id="ref-frosi2023" class="csl-entry quarto-appendix-citeas">
Frosi, Gustavo, and Dayana Eckert. 2023. <span>“Trabalhos - XXIII CLACS
| XXXVIII CBCS.”</span> December 17. <a href="https://doi.org/10.59350/k52fq-pv005">https://doi.org/10.59350/k52fq-pv005</a>.
</div></div></section></div> ]]></description>
  <category>R</category>
  <category>Solos</category>
  <guid>https://gustavofrosi.com.br/recap/2023-12-17-CBCS-2023/</guid>
  <pubDate>Sun, 17 Dec 2023 03:00:00 GMT</pubDate>
  <media:content url="https://gustavofrosi.com.br/recap/2023-12-17-CBCS-2023/logo.png" medium="image" type="image/png" height="70" width="144"/>
</item>
</channel>
</rss>
