generated from curso-r/template-pagina-do-curso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelatorio_b3.qmd
81 lines (63 loc) · 1.36 KB
/
relatorio_b3.qmd
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
---
title: "Relatório parametrizado"
author: "Fernando Corrêa"
data: "2024-11-04"
lang: pt
format:
html:
embed-resources: true
knitr:
opts_chunk:
echo: false
erro: false
warning: false
message: false
params:
data_minima: "2024-10-01"
data_maxima: "2024-10-31"
incluir_grafico_retornos: true
---
```{r}
library(tidyverse)
library(rbcb)
ggplot2::theme_set(
theme_minimal()
)
```
```{r}
dados <- get_currency("USD",params$data_minima, params$data_maxima)
```
# Relatório sobre o dolar
## Resumo atual
```{r}
variacoes_diarias <- dados |>
arrange(date) |>
mutate(
retorno = bid/lag(bid)-1
)
data_ref <- max(dados$date)
valor_referencia <- dados |>
filter(date == data_ref) |>
pull(bid)
variacao_diaria <- variacoes_diarias |>
filter(date == data_ref) |>
pull(retorno)
```
- Período de referência: Entre `r params$data_minima` e `r params$data_maxima`
- Último dia registrado na base: `r data_ref`
- Valor em `r data_ref`: `r valor_referencia`
- Variação no último dia: `r variacao_diaria`
## Série histórica
```{r}
dados |>
ggplot(aes(x = date, y = bid)) +
geom_line()
```
```{r, include = params$incluir_grafico_retornos, results='asis'}
cat('<h2>Série de retornos</h2>')
```
```{r, include = params$incluir_grafico_retornos}
variacoes_diarias |>
ggplot(aes(x = date, y = retorno)) +
geom_point()
```