class: center, middle, inverse, title-slide # Pintando e bordando no R ## ggplot2 e rmarkdown ### Rodrigo Citton P. dos Reis
em colaboração com Markus C. Stein, Márcia H. Barbian
e Silvana Schneider
Departmento de Estatística ###
IX SEMANÍSTICA e 1º Datathon da UFRGS
Porto Alegre, 15 de outubro de 2018 --- background-image: url("images/logo_semanistica_datathon2.png") --- background-image: url("images/logo_40anos_ppgest2.png") --- # Estatística e Ciência dos dados <img src="images/tobeornottobe1.jpg" width="45%" style="display: block; margin: auto;" /> --- # Estatística e Ciência dos dados <img src="images/data_science_diagram2.png" width="90%" style="display: block; margin: auto;" /> .footnote[ [**Fonte:** Efron, B. e Hastie, T. (2016). *Computer Age Statistical Inference: Algorithms, Evidence, and Data Science*. Cambridge: Cambridge University Press.](https://web.stanford.edu/~hastie/CASI_files/PDF/casi.pdf) ] --- <img src="images/datascientist_infographic.jpg" width="76%" style="display: block; margin: auto;" /> --- class: inverse, middle, center background-image: url("images/pintando_bordando_colmeia.png") background-size: contain --- class: inverse background-image: url("images/vai_precisar.JPG") background-size: contain # Você vai precisar de ... - [R](https://www.r-project.org) - [RStudio](https://www.rstudio.com) é recomendável, mas não é necessário. - Pacotes principais: + [ggplot2](https://ggplot2.tidyverse.org) + [rmarkdown](https://rmarkdown.rstudio.com) - Pacotes auxiliares: + [knitr](https://yihui.name/knitr/) + [plyr](https://rmarkdown.rstudio.com/) + [gapminder](https://rmarkdown.rstudio.com/) - Banco de dados: + **gapminder** do pacote `gapminder` - **Arquivos de apoio:** + https://www.ufrgs.br/datathon --- class: inverse, middle, center background-image: url("images/hex-ggplot2.png") background-size: contain --- # O que é o ggplot2? .pull-left[ <img src="images/hadley1.jpg" width="100%" style="display: block; margin: auto;" /> ] .pull-right[ - Implementação em **R** da **Gramática dos Gráficos** (*Grammar of the Graphics*; **gg**) de **Leland Wilkinson**<sup>1</sup> por **Hadley Wickham**<sup>2</sup>. - **Pergunta:** que é um gráfico estatístico? + **gg:** é um mapeamento dos dados a partir de **atributos estéticos** (cores, formas, tamanho) de **formas geométricas** (pontos, linhas, barras) ] .footnote[ [1] Wilkinson, L. (2005). *The Grammar of Graphics*. Springer; 2nd edition. [2] Wickham, H. (2016). *ggplot2: Elegant Graphics for Data Analysis*. Springer; 2nd edition. ] --- # Por que ggplot2? .pull-left[ Um gráfico do pacote **graphics** <img src="index_files/figure-html/unnamed-chunk-5-1.png" width="100%" style="display: block; margin: auto;" /> ] .pull-right[ Um gráfico do pacote **ggplot2** <img src="index_files/figure-html/unnamed-chunk-6-1.png" width="100%" style="display: block; margin: auto;" /> ] --- # Por que ggplot2? .pull-left[ Um gráfico do pacote **graphics** <img src="index_files/figure-html/unnamed-chunk-7-1.png" width="100%" style="display: block; margin: auto;" /> ] .pull-right[ Um gráfico do pacote **ggplot2** <img src="index_files/figure-html/unnamed-chunk-8-1.png" width="100%" style="display: block; margin: auto;" /> ] --- # Camadas! - No **ggplot2**, um gráfico é feito por camadas. <img src="images/camadas2.png" width="70%" style="display: block; margin: auto;" /> --- background-image: url("images/totoro_danca2.gif") background-size: cover class: center, inverse # Vamos lá! --- # Instalando e carregando o ggplot2 - Instalando o pacote **ggplot2** ```r install.packages("ggplot2") ``` - Carregando o pacote **ggplot2** ```r library(ggplot2) ``` --- # O banco de dados - Carregando o banco de dados **gapminder** ```r # install.packages("gapminder") library(gapminder) gapminder ``` ``` ## # A tibble: 1,704 x 6 ## country continent year lifeExp pop gdpPercap ## <fct> <fct> <int> <dbl> <int> <dbl> ## 1 Afghanistan Asia 1952 28.8 8425333 779. ## 2 Afghanistan Asia 1957 30.3 9240934 821. ## 3 Afghanistan Asia 1962 32.0 10267083 853. ## 4 Afghanistan Asia 1967 34.0 11537966 836. ## 5 Afghanistan Asia 1972 36.1 13079460 740. ## 6 Afghanistan Asia 1977 38.4 14880372 786. ## 7 Afghanistan Asia 1982 39.9 12881816 978. ## 8 Afghanistan Asia 1987 40.8 13867957 852. ## 9 Afghanistan Asia 1992 41.7 16317921 649. ## 10 Afghanistan Asia 1997 41.8 22227415 635. ## # ... with 1,694 more rows ``` --- # O banco de dados - `gdpPercap`: **renda per capita** ("PIB/Pop"). - `lifeExp`: **expectativa de vida** ao nascer (número de anos aproximados que se espera que um grupo de indivíduos nascidos no mesmo ano irá viver). - `year`: 1952 a 2007 em incrementos de 5 anos. ```r library(dplyr) gapminder <- gapminder %>% mutate(pop_m = pop/1e6) gapminder07 <- gapminder %>% filter(year == 2007) ``` --- # Camadas: dados ```r p <- ggplot(data = gapminder07) p ``` <img src="index_files/figure-html/unnamed-chunk-14-1.png" width="50%" style="display: block; margin: auto;" /> ```r # print(p) ``` --- background-image: url("images/tenor.gif") background-size: cover class: center, inverse # Camadas: estética --- # Camadas: elementos estéticos ```r p <- ggplot(data = gapminder07, mapping = aes(x = gdpPercap, y = lifeExp)) p ``` <img src="index_files/figure-html/unnamed-chunk-15-1.png" width="50%" style="display: block; margin: auto;" /> --- # Camadas: elementos estéticos - Os dois elementos estéticos mais importantes são os eixos `x` e `y` do gráfico. - Existem outros elementos estéticos **(mais variáveis podem ser incorporadas ao gráfico)** que devem ser especificados de acordo com o tipo de gráfico. + `color` ou `colour` + `fill` + `size` + `group` - Veremos a utilização destes elementos na sequência. --- # Camadas: elementos geométricos ```r p <- ggplot(data = gapminder07, mapping = aes(x = gdpPercap, y = lifeExp)) + * geom_point() p ``` <img src="index_files/figure-html/unnamed-chunk-16-1.png" width="50%" style="display: block; margin: auto;" /> --- # Camadas: elementos geométricos - O gráfico anterior é um **diagrama de dispersão** (*scatter plot*) e é definido pela função `geom_point()`. + Este é acrescentado ao gráfico com o **operador** `+`. - Diferentes elementos geométricos definem diferentes tipos de gráficos. Os principais são listadas a seguir: + `geom_histogram()`: gera um histograma + `geom_line()`: gera um gráfico de linha + `geom_boxplot()`: gera um diagrama de caixa (boxplot) + `geom_bar()`: gera um gráfico de barras/colunas + `geom_density()`: gera um gráfico da densidade estimada (por *kernel*) + `geom_violin()`: gera um gráfico de violino (mistura de boxplot com densidade estimada) - Para uma lista completa de `geoms` veja: https://ggplot2.tidyverse.org/reference/index.html#section-layer-geoms. - **Elementos estéticos** (`aes()`) podem ser passados para cada `geom`. --- background-image: url("images/totoro_bambole.gif") background-size: cover class: center, inverse # Exemplos! --- ```r # Histograma p <- ggplot(data = gapminder07, mapping = aes(x = lifeExp)) + geom_histogram() p ``` <img src="index_files/figure-html/unnamed-chunk-17-1.png" width="60%" style="display: block; margin: auto;" /> --- ```r # Densidade estimada p <- ggplot(data = gapminder07, mapping = aes(x = lifeExp)) + geom_density() p ``` <img src="index_files/figure-html/unnamed-chunk-18-1.png" width="60%" style="display: block; margin: auto;" /> --- ```r # Densidade estimada (grupos) p <- ggplot(data = gapminder07, mapping = aes(x = lifeExp, fill = continent)) + geom_density(alpha = 0.3) p ``` <img src="index_files/figure-html/unnamed-chunk-19-1.png" width="60%" style="display: block; margin: auto;" /> --- ```r # Gráfico de barras p <- ggplot(data = gapminder07, mapping = aes(x = continent)) + geom_bar() p ``` <img src="index_files/figure-html/unnamed-chunk-20-1.png" width="60%" style="display: block; margin: auto;" /> --- ```r # Boxplot p <- ggplot(data = gapminder07, mapping = aes(x = continent, y = pop_m)) + geom_boxplot() p ``` <img src="index_files/figure-html/unnamed-chunk-21-1.png" width="60%" style="display: block; margin: auto;" /> --- ```r # Gráfico de violino p <- ggplot(data = gapminder07, mapping = aes(x = continent, y = pop_m)) + geom_violin() p ``` <img src="index_files/figure-html/unnamed-chunk-22-1.png" width="60%" style="display: block; margin: auto;" /> --- ```r # Gráfico de linha p <- ggplot(data = gapminder[which(gapminder$country == "Brazil"),], mapping = aes(x = year, y = lifeExp)) + geom_line(size = 1) p ``` <img src="index_files/figure-html/unnamed-chunk-23-1.png" width="60%" style="display: block; margin: auto;" /> --- ```r # Gráfico de linha p <- ggplot(data = gapminder[which(gapminder$continent == "Americas"),], mapping = aes(x = factor(year), y = lifeExp, group = country, color = country)) + geom_line(size = 1) + geom_point() p ``` <img src="index_files/figure-html/unnamed-chunk-24-1.png" width="62%" style="display: block; margin: auto;" /> --- background-image: url("images/totoro_corda.gif") background-size: cover class: center, inverse # Exercício 1 --- - Acrescente as variáveis continente (`continent`) e população (`pop` ou `pop_m`) ao gráfico abaixo. <img src="index_files/figure-html/unnamed-chunk-25-1.png" width="60%" style="display: block; margin: auto;" /> --- ```r p <- ggplot(data = gapminder07, mapping = aes(x = gdpPercap, y = lifeExp, color = continent, size = pop_m)) + geom_point(alpha = 0.3) + geom_text(aes(label = country), color = "gray20") p ``` <img src="index_files/figure-html/unnamed-chunk-26-1.png" width="65%" style="display: block; margin: auto;" /> --- ```r p + geom_smooth(method = "lm") ``` <img src="index_files/figure-html/unnamed-chunk-27-1.png" width="65%" style="display: block; margin: auto;" /> --- ```r p + geom_smooth(mapping = aes(x = gdpPercap, y = lifeExp, color = NULL), method = "lm") ``` <img src="index_files/figure-html/unnamed-chunk-28-1.png" width="65%" style="display: block; margin: auto;" /> --- ```r p + geom_smooth(mapping = aes(x = gdpPercap, y = lifeExp, color = NULL), method = "lm", formula = y ~ x + log(x), se = FALSE, color = "red") ``` <img src="index_files/figure-html/unnamed-chunk-29-1.png" width="65%" style="display: block; margin: auto;" /> --- # Camadas: facetas ```r p <- ggplot(data = gapminder, mapping = aes(x = gdpPercap, y = lifeExp)) + geom_point() + * facet_grid(. ~ year) p ``` <img src="index_files/figure-html/unnamed-chunk-30-1.png" width="50%" style="display: block; margin: auto;" /> --- # Camadas: facetas ```r p <- ggplot(data = gapminder, mapping = aes(x = gdpPercap, y = lifeExp, color = continent)) + geom_point() + * facet_wrap(. ~ year) p ``` <img src="index_files/figure-html/unnamed-chunk-31-1.png" width="50%" style="display: block; margin: auto;" /> --- # Camadas: facetas ```r gapminder$gdpPercap.cat <- cut(gapminder$gdpPercap, breaks = c(0, 1005, 3955, 12235, Inf), labels = c("Baixa-renda", "Renda média-baixa", "Renda média-alta", "Renda alta")) p <- ggplot(data = gapminder, mapping = aes(x = factor(year), y = lifeExp, fill = factor(year))) + geom_boxplot() + * facet_grid(continent ~ gdpPercap.cat) p ``` --- # Camadas: facetas <img src="index_files/figure-html/unnamed-chunk-33-1.png" width="70%" style="display: block; margin: auto;" /> --- # Eixos e rótulos ```r p <- ggplot(data = gapminder07, mapping = aes(x = gdpPercap, y = lifeExp, color = continent, size = pop_m)) + geom_point(alpha = 0.3) p ``` <img src="index_files/figure-html/unnamed-chunk-34-1.png" width="60%" style="display: block; margin: auto;" /> --- # Eixos e rótulos ```r p + labs(x = "Renda per capita (US$)", y = "Expectativa de vida (anos)", color = "Continente", size = "População/1 milhão") ``` <img src="index_files/figure-html/unnamed-chunk-35-1.png" width="60%" style="display: block; margin: auto;" /> --- # Legendas e temas .pull-left[ ```r p + theme(legend.position = "none") ``` <img src="index_files/figure-html/unnamed-chunk-37-1.png" width="100%" style="display: block; margin: auto;" /> ] .pull-right[ ```r p + theme(legend.position = "top") ``` <img src="index_files/figure-html/unnamed-chunk-38-1.png" width="100%" style="display: block; margin: auto;" /> ] --- # Temas - Existem diversos outros elementos do tema de um gráfico que podem ser controlados por argumentos da função `theme()`. ```r p + theme(text = element_text(color = "gray20"), legend.position = c("top"), # posição da legenda legend.direction = "horizontal", legend.justification = 0.1, # ponto de ancora para legend.position. legend.text = element_text(size = 11, color = "gray10"), axis.text = element_text(face = "italic"), axis.title.x = element_text(vjust = -1), axis.title.y = element_text(vjust = 2), axis.ticks.y = element_blank(), # element_blank() é como removemos elementos axis.line = element_line(color = "gray40", size = 0.5), axis.line.y = element_blank(), panel.grid.major = element_line(color = "gray50", size = 0.5), panel.grid.major.x = element_blank()) ``` --- # Temas <img src="index_files/figure-html/unnamed-chunk-40-1.png" width="70%" style="display: block; margin: auto;" /> --- background-image: url("images/ufa-homer-1.jpg") background-size: cover # Temas pré-definidos - O pacote **ggplot2** possui alguns temas pré-definidos! Alguns exemplos são: + `theme_bw()`: *black and white* + `theme_minimal()`: mínimo + `theme_classic()`: semelhante aos gráficos do pacote **graphics** + `theme_dark()`: escuro --- # Temas pré-dfinidos ```r p + theme_bw() ``` <img src="index_files/figure-html/unnamed-chunk-41-1.png" width="60%" style="display: block; margin: auto;" /> --- # Temas pré-definidos II: o pacote ggthemes .pull-left[ <img src="images/e2b.jpg" width="100%" style="display: block; margin: auto;" /> ] .pull-right[ - O pacote [**ggthemes**](https://yutannihilation.github.io/allYourFigureAreBelongToUs/ggthemes/) possui uma série de outros temas pré-definidos! ```r # install.packages("ggthemes") library(ggthemes) ``` ] --- # Temas pré-dfinidos II: ggthemes .pull-left[ ```r # Wall Street Journal p + theme_wsj() ``` <img src="index_files/figure-html/unnamed-chunk-44-1.png" width="100%" style="display: block; margin: auto;" /> ] .pull-right[ ```r # The Economist p + theme_economist() ``` <img src="index_files/figure-html/unnamed-chunk-45-1.png" width="100%" style="display: block; margin: auto;" /> ] --- # ggplot: um resumo esquemático <img src="images/ggplot-formula-schematic.png" width="100%" style="display: block; margin: auto;" /> --- # Salvando um gráfico .pull-left[ - Você pode salvar o último gráfico realizado com a função `ggsave()` ```r ggsave("MeuPrimeiroGGPLOT.pdf") ggsave("MeuPrimeiroGGPLOT.png") ggsave("MeuPrimeiroGGPLOT.jpg", width = 4, height = 4) ``` ] .pull-right[ - Ou ainda, utilizando as funcionalidades do RStudio <img src="images/ggsave_manual.png" width="100%" style="display: block; margin: auto;" /> ] --- # Considerações finais - Existem diversos pacotes que foram criados para complementar o **ggplot2**. + **ggthemes** + **grid** + **magick** + **plotly** + **jcolors** - Juntos, estes pacotes tem um potencial quase ilimitado para a geração de gráficos no **R**. --- ```r # Considerações finais: exemplos # install.packages("jpeg") # install.packages("grid") library(jpeg) library(grid) img <- readJPEG("~/PintandoEBordando/ArquivosR/images/hans_rosling.jpg") # start plotting p <- ggplot(data = gapminder07, mapping = aes(x = gdpPercap, y = lifeExp, color = continent, size = pop_m)) + annotation_custom(rasterGrob(img, width = unit(1, "npc"), height = unit(1, "npc")), -Inf, Inf, -Inf, Inf) + scale_y_continuous(expand = c(0,0), limits = c(min(gapminder07$lifeExp) * 0.9, max(gapminder07$lifeExp) * 1.05)) + geom_point() + labs(x = "Renda per capita (US$)", y = "Expectativa de vida (anos)", color = "Continente", size = "População/1 milhão") + theme_bw() + theme(text = element_text(color = "gray20"), legend.position = c("top"), # posição da legenda legend.direction = "horizontal", legend.justification = 0.1, # ponto de ancora para legend.position. legend.text = element_text(size = 11, color = "gray10"), axis.text = element_text(face = "italic"), axis.title.x = element_text(vjust = -1), axis.title.y = element_text(vjust = 2), axis.ticks.y = element_blank(), # element_blank() é como removemos elementos axis.line = element_line(color = "gray40", size = 0.5), axis.line.y = element_blank(), panel.grid.major = element_line(color = "gray50", size = 0.5), panel.grid.major.x = element_blank() ) p ``` <img src="index_files/figure-html/unnamed-chunk-49-1.png" width="100%" style="display: block; margin: auto;" /> --- <img src="index_files/figure-html/unnamed-chunk-50-1.png" width="70%" style="display: block; margin: auto;" /> --- ```r # Considerações finais: exemplos - interatividade p <- ggplot(data = gapminder07, mapping = aes(x = gdpPercap, y = lifeExp, color = continent, size = pop_m)) + geom_point() + labs(x = "Renda per capita (US$)", y = "Expectativa de vida (anos)", color = "Continente", size = "População/1 milhão") + theme_bw() p ``` <img src="index_files/figure-html/unnamed-chunk-51-1.png" width="60%" style="display: block; margin: auto;" /> --- ```r # Considerações finais: exemplos - interatividade # install.packages("plotly") library(plotly) ggplotly(p) ```
--- background-image: url("images/porquecomprar-v2.gif") background-size: cover class: center, middle, inverse # Perguntas!?! --- class: inverse, middle, center background-image: url("images/rmarkdown.png") background-size: contain --- # O que é o rmarkdown<sup>1</sup>? .pull-left[ <img src="images/yihui1.jpg" width="100%" style="display: block; margin: auto;" /> ] .pull-right[ <img src="images/rstudio-hex-knitr-dot-psd.png" width="40%" style="display: block; margin: auto;" /> - **R** (códigos) + **Markdown** (linguagem **simples** de marcação para geração de **texto**) + [**Pandoc**](http://pandoc.org/) (conversor universal de documentos) ] .footnote[ [1] Allaire, J.J., Xie, Y., McPherson, J., Luraschi, J., Ushey, K., Atkins, A., Wickham, H., Cheng, J. e Chang, W. (2018). *rmarkdown: Dynamic Documents for R*. R package version 1.10. ] --- background-image: url("images/bandThree2.png") background-size: cover # O fluxo do rmarkdown? <img src="images/rmarkdownflow.png" width="100%" style="display: block; margin: auto;" /> - Quando compilado, o **R Markdown** alimenta o arquivo .Rmd para **knitr**, que executa todos os fragmentos de código e cria um novo documento markdown (.md) que inclui o código e sua saída. - O arquivo markdown gerado pelo **knitr** é então processado pelo **pandoc**⧉ que é responsável pela criação do formato final. - Isso pode parecer complicado, mas o **R Markdown** torna extremamente simples encapsulando todo o processamento acima em uma única função de renderização. --- # Por que rmarkdown? <img src="images/r_comunica.png" width="100%" style="display: block; margin: auto;" /> - Vamos a um exemplo! --- background-image: url("images/totoro_danca.gif") background-size: cover class: center, inverse # Vamos lá! --- # Instalando e carregando o rmarkdown - Instalando o pacote **rmarkdown** ```r install.packages("rmarkdown") ``` - Carregando o pacote **rmarkdown** ```r library(rmarkdown) ``` --- # Criando um documento R markdown - Clique em `File -> New File -> R Markdown` <img src="images/rmd_print_1.png" width="55%" style="display: block; margin: auto;" /> --- # Criando um documento R markdown - Agora você deve ver uma caixa de diálogo como mostrado abaixo. - Selecione "Document" no painel à esquerda e preencha o campo de título e autor e clique em "OK". <img src="images/rmd_print_2.png" width="60%" style="display: block; margin: auto;" /> --- # Criando um documento R markdown - Agora você deve ter um documento que parece com isso <img src="images/rmd_print_3.png" width="100%" style="display: block; margin: auto;" /> --- # YAML - Um conjunto de opções que definem o arquivo de saída .pull-left[ - Este documento gera um arquivo `html` ```yaml --- title: "Exemplo 1 - Rmd" author: "Rodrigo Citton P. dos Reis" date: "15 de outubro de 2018" output: html_document --- ``` ] .pull-right[ - Este documento gera um arquivo `word` ```yaml --- title: "Exemplo 1 - Rmd" author: "Rodrigo Citton P. dos Reis" date: "15 de outubro de 2018" output: word_document --- ``` ] --- # Markdown: sintaxe básica .pull-left[ ``` texto simples _italico_ __negrito__ [Datahon](https://www.ufrgs.br/datathon) # Título 1 ## Título 2 ### Título 3 ``` ] .pull-right[ texto simples _italico_ __negrito__ [Datahon](https://www.ufrgs.br/datathon) ## Título 1 ### Título 2 #### Título 3 ] --- # Markdown: sintaxe básica .pull-left[ ``` - Lista não ordenada - item 2 + sub-item 1 + sub-item 2 1. Lista ordenada 2. item 2 + sub-item 1 + sub-item 2 Cabeçalho tabela | Segundo cabeçalho ---------------- | ----------------- Célula tabela | Célula 2 Célula 3 | Célula 4 ``` ] .pull-right[ - Lista não ordenada - item 2 + sub-item 1 + sub-item 2 1. Lista ordenada 2. item 2 + sub-item 1 + sub-item 2 Cabeçalho tabela | Segundo cabeçalho ---------------- | ----------------- Célula tabela | Célula 2 Célula 3 | Célula 4 ] --- background-image: url("images/chuky.gif") background-size: cover class: center, inverse # Chunk! --- # Chunk - Os códigos em **R** são passados para o arquivo .Rmd por meio de fragmentos de código (_chunk codes_). - Um exemplo de chunk: ```{r} summary(gapminder07$pop_m) ``` - Saída: ```r summary(gapminder07$pop_m) ``` ``` ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## 0.1996 4.5080 10.5175 44.0212 31.2100 1318.6831 ``` --- # Chunk ```{r, echo=FALSE} summary(gapminder07$pop_m) ``` - Saída: ``` ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## 0.1996 4.5080 10.5175 44.0212 31.2100 1318.6831 ``` --- # Chunk ```{r, eval=FALSE} summary(gapminder07$pop_m) ``` - Saída: ```r summary(gapminder07$pop_m) ``` --- # Chunk ```{r, echo=FALSE, results='asis'} library(knitr) mod1 <- lm(lifeExp ~ gdpPercap, data = gapminder07) kable(summary(mod1)$coef, format = "html") ``` - Saída: <table> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:right;"> Estimate </th> <th style="text-align:right;"> Std. Error </th> <th style="text-align:right;"> t value </th> <th style="text-align:right;"> Pr(>|t|) </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> (Intercept) </td> <td style="text-align:right;"> 59.5656501 </td> <td style="text-align:right;"> 1.0104086 </td> <td style="text-align:right;"> 58.95204 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> gdpPercap </td> <td style="text-align:right;"> 0.0006371 </td> <td style="text-align:right;"> 0.0000583 </td> <td style="text-align:right;"> 10.93340 </td> <td style="text-align:right;"> 0 </td> </tr> </tbody> </table> --- background-image: url("images/totoro_jumpingjack.gif") background-size: cover class: center, inverse # Exercício 1! --- 1. Crie um arquivo .Rmd. 2. Acrescente texto e a análise do arquivo **exemplo-rmarkdown-1.R** 3. Clique em `knit` para gerar o arquivo de saída. <img src="images/rmd_print_4.png" width="100%" style="display: block; margin: auto;" /> - Experimente gerar diferentes formatos de saída. <img src="images/rmd_print_5.png" width="100%" style="display: block; margin: auto;" /> --- # Por que rmarkdown? <img src="images/r_comunica.png" width="100%" style="display: block; margin: auto;" /> - Reprodutibilidade - Dinamismo - Eficiência - Velocidade --- background-image: url("images/totoro_bola.gif") background-size: cover class: center, inverse # Um último exemplo! --- background-image: url("images/porquecomprar-v2.gif") background-size: cover class: center, middle, inverse # Perguntas!?! --- background-image: url("images/stat_caco.gif") background-size: cover class: middle, center, inverse # Muito obrigado! ## https://www.ufrgs.br/datathon ### https://github.com/datathon-ufrgs/Pintando_e_Bordando_no_R ### rodrigocpdosreis@gmail.com