Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
bttomio committed Sep 25, 2023
1 parent ce3a614 commit 45df3ed
Show file tree
Hide file tree
Showing 9 changed files with 934 additions and 0 deletions.
39 changes: 39 additions & 0 deletions slides/OficinaPPGCC/Dia2.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: "Oficina PPGCC - Programação em R"
author: "Seu nome"
date: "`r Sys.Date()`"
output: pdf_document
bibliography: references.bib
link-citations: true
linkcolor: green
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Trazendo informações da base de dados

## Exemplo da Karsten

No ano de `r painelmoeda$ano[[991]]`, a empresa `r painelmoeda$nome[[991]]` (`r painelmoeda$Identifier[[991]]`) teve receita total igual a `r painelmoeda$RT[[991]]` milhões.

Por outro lado, as empresas do seu setor *`r painelmoeda$setor[[991]]`* tiveram receita total média de `r mediasetor$RT[[18]]` milhões.

Segundo @matsumoto2012, ...

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

# References
Binary file added slides/OficinaPPGCC/Dia2.pdf
Binary file not shown.
58 changes: 58 additions & 0 deletions slides/OficinaPPGCC/Programação em R.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
###### PRIMEIRA PARTE ######

#### INSTALAR/CARREGAR AS BIBLIOTECAS NECESSÁRIAS
## REMOVA "#" E EXECUTE A LINHA (CTRL + ENTER)
## APÓS A INSTALAÇÃO, ADICIONE NOVAMENTE "#" PARA EVITAR REFAZER A INSTALAÇÃO

install.packages(c("tidyverse", "readxl", "vctrs",
"scales"))

#tinytex::install_tinytex()

#### CARREGAR OS DADOS
# BASE FORNECIDA PELO ADHMIR R. V. GOMES
# MODIFICADA MANUALMENTE

# USE O CAMINHO:
# FILE -> IMPORT DATASET -> FROM EXCEL...

library(readxl)
#exemplo <- read_excel("exemplo.xlsx")

# AJUSTAR A BASE PARA FORMATO EM PAINEL

library(tidyverse)

painel <-
pivot_longer(exemplo, cols = -c(1:5), names_to = c(".value", "ano"),
names_sep = "\\.") %>%
arrange(`Company Name`)

names(painel)

painel <-
rename(painel, nome = `Company Name`) %>%
rename(hq = `Country of Headquarters`) %>%
rename(exchange = `Country of Exchange`) %>%
rename(setor = `TRBC Economic Sector Name`)

# AJUSTES DE FORMATAÇÃO DOS VALORES

library(scales)
painelmoeda <- painel %>%
mutate_at(c("ATC", "PTC", "ATR", "EBITDA", "RT"),
label_dollar(prefix = "R$ ",
decimal.mark = ",",
big.mark = "."))

# Média de RT por setor

mediasetor <-
group_by(painel, setor, ano) %>%
summarize(RT = mean(RT, na.rm = TRUE)) %>%
mutate_at(c("RT"),
label_dollar(prefix = "R$ ",
decimal.mark = ",",
big.mark = ".",
accuracy = 1))

Loading

0 comments on commit 45df3ed

Please sign in to comment.