---
title: "Graficos"
author: "Neil Franz Cabanillas Jurado"
date: "`r format(Sys.Date(), '%d %B,%Y')`"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source: embed
social: menu
---
```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(lattice)
library(lessR)
library(plotrix)
library(RColorBrewer)
library(KernSmooth)
```
# Histogramas {data-icon="fa-chart-bar"}
Column {data-width=333}
-----------------------------------------------------------------------
### dpih()
```{r dpih.fig.align='center'}
distancia <- c(241.1, 284.4, 220.2, 272.4, 271.1, 268.3,
291.6, 241.6, 286.1, 285.9, 259.6, 299.6,
253.1, 239.6, 277.8, 263.8, 267.2, 272.6,
283.4, 234.5, 260.4, 264.2, 295.1, 276.4,
263.1, 251.4, 264.0, 269.2, 281.0, 283.2)
ancho_barras <- dpih(distancia)
nbarras <- seq(min(distancia) - ancho_barras,
max(distancia) + ancho_barras, by = ancho_barras)
hist(distancia, breaks = nbarras, main = "Plug-in", ylab = "Frecuencia")
```
Column {data-width=333}
-----------------------------------------------------------------------
### grid
```{r grid.fig.align='center'}
hist(distancia, prob = TRUE, ylab = "Densidad", main = "Grid")
grid(nx = NA, ny = NULL, lty = 2, col = "gray", lwd = 1)
hist(distancia, prob = TRUE, add = TRUE, col = "white")
```
Column {data-width=333}
-----------------------------------------------------------------------
### Dos Variables (rnorm)
```{r rnorm.fig.align='center'}
set.seed(1)
x <- rnorm(1000) # Primer grupo
y <- rnorm(1000, 1) # Segundo grupo
hist(x, main = "Dos variables", ylab = "Frecuencia")
hist(y, add = TRUE, col = rgb(1, 0, 0, alpha = 0.5))
```
# Pie 01 {data-icon="fa-chart-pie"}
Column {data-width=999}
-----------------------------------------------------------------------
```{r barplot_01,fig.align='center'}
count <- c(7, 25, 16, 12, 10, 30)
par(mfrow = c(1, 3))
pie(count, labels = count, col = 1:6, cex = 2)
pie(count, labels = count, col = rainbow(6), cex = 2)
pie(count, labels = count, col = topo.colors(6), cex = 2)
par(mfrow = c(1, 1))
```
# Pie 02 {data-icon="fa-chart-pie"}
Column {data-width=999}
-----------------------------------------------------------------------
```{r,fig.align='center'}
count_3 <- c(20, 50, 30)
# sum(count_3) # 100
pie(count_3, labels = paste0(count_3, "%"))
legend("topleft", legend = c("Teatro", "Series", "Cine"),
fill = c("white", "lightblue", "mistyrose"))
```
# Pie 03 {data-icon="fa-chart-pie"}
Column {data-width=1000}
-----------------------------------------------------------------------
```{r,fig.align='center'}
datos <- c(65, 35)
pie3D(datos, labels = datos)
```