---
title: "Visualização de dados com R"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
social: [ "twitter", "facebook", "menu"]
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(knitr)
library(DT)
library(rpivotTable)
library(ggplot2)
library(plotly)
library(dplyr)
library(openintro)
library(highcharter)
library(ggvis)
library(plotly)
library(treemap)
library(ggridges)
library(corrplot)
```
```{r}
data <- read.csv("https://raw.githubusercontent.com/DATAUNIRIO/Base_de_dados/master/Fam%C3%ADlias.csv",sep=";",dec=",")
mycolors <- c("blue", "red", "darkgreen", "darkorange")
```
Visualização de Dados
=====================================
Row
---------------------------
### Característica da turma
```{r}
valueBox(paste("Turma Estatística"),
color = "green")
```
### Quantidade de estudantes
```{r}
valueBox(dim(data)[1])
```
### **Média de renda**
```{r}
gauge(round(mean(data$renda),
digits = 2),
min = 0,
max = 26)
```
### Ensino fundamental
```{r}
valueBox(sum(data$instr == "Ensino fundamental")
)
```
### Ensino médio
```{r}
valueBox(sum(data$instr == "Ensino médio"),
icon = 'fa-tag')
```
### Sem Instrução
```{r}
valueBox(sum(data$instr == "Sem Instrução"),
icon = 'fa-building')
```
### Monte Verde
```{r}
valueBox(sum(data$local == "Monte Verde"),
icon = 'fa-building')
```
Row {.tabset .tabset-fade}
-------------------------------
### Quantidade de estudantes por bairro
```{r}
p1 <- data %>%
group_by(local) %>%
summarise(count = n()) %>%
plot_ly(x = ~local,
y = ~ count,
color = "blue",
type = 'bar') %>%
layout(xaxis = list(title = "local"),
yaxis = list(title = 'Frequência Absoluta'))
p1
```
### Boxplot Altura x Sexo
```{r}
p2 <- plot_ly(data, x = ~factor(p.a.p), y = ~renda) %>%
add_boxplot()
p2
```
### Dispersão
```{r}
p4 <- plot_ly(data, x=~renda) %>%
add_markers(y = ~tam,
text = ~paste("Tamanho: ", tam),
showlegend = F) %>%
layout(xaxis = list(title = "tam"),
yaxis = list(title = "renda"))
p4
```
### Tree map
```{r}
# treemap
treemap(data,
index=c("local","instr"),
vSize="renda",
type="index"
)
```
Data Table
========================================
```{r}
datatable(data,
caption = "Familia",
rownames = T,
filter = "top",
options = list(pageLength = 10))
```
Pivot Table
=========================================
```{r}
rpivotTable(data,
rendererName = "Heatmap")
```
Dispersao
=========================================
```{r}
ggplot(data, aes(x=tam, y=renda, fill=renda)) +
geom_label(label=rownames(data), color="white", size=5)
```
Joyplot
=========================================
```{r}
ggplot(data, aes(x = renda, y = local, fill = local)) +
geom_density_ridges() +
theme_ridges() +
theme(legend.position = "none")
```
Corrplot
=========================================
```{r}
data("mtcars")
M <- cor(mtcars[,c("disp","drat","hp","mpg","qsec","wt")],method="spearman")
corrplot.mixed(M)
```