-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
934 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
|
Oops, something went wrong.