---
title: "Bar Charts"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
theme: united
social: ['facebook','twitter','linkedin','pinterest','github']
source: embed
---
```{r setup, include=FALSE}
library(ggplot2)
library(lattice)
library(flexdashboard)
```
# BarChart_01 {data-icon=fa-bar-chart}
Column {data-width=333}
-----------------------------------------------------------------------
### barplot()
```{r,fig.align='center'}
x <- table(mtcars$cyl)
colores <- c("orange","blue","purple")
barplot(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores)
```
Column {data-width=333}
-----------------------------------------------------------------------
### ggplot2
```{r,fig.align='center'}
ggplot(mtcars,aes(cyl)) + geom_bar(fill=colores) + labs(x="Cillindros",y="Frecuencias",title="Número de Cilindros") + theme_dark()
```
Column {data-width=333}
-----------------------------------------------------------------------
### lattice
```{r,fig.align='center'}
barchart(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores,horizontal=FALSE)
```
# BarChart_02 {data-icon=fa-bar-chart}
Column {data-width=500}
--------------------------------------------------------------------------
### cyl
```{r,fig.align='center'}
x <- table(mtcars$cyl)
colores <- c("orange","blue","purple")
barplot(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores)
```
Column {data-width=500}
---------------------------------------------------------------------------
### cyl_gear
```{r,fig.align='center'}
y <- table(mtcars$gear)
par(mfrow=c(1,2))
barplot(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores)
barplot(y,xlab="Engranajes",ylab="Frecuencias",main="Número de Engranajes",col=rainbow(3))
```
# BarCharts_03 {data-icon=fa-bar-chart}
### var_gear
```{r,fig.align='center'}
y <- table(mtcars$gear)
barplot(y,xlab="Engranajes",ylab="Frecuencias",main="Número de Engranajes",col=rainbow(3))
```
# BarCharts_04 {data-icon=fa-bar-chart}
## {.tabset}
### Diagrama Barras
```{r}
ggplot(mtcars,aes(cyl)) + geom_bar(fill=colores) + labs(x="Cillindros",y="Frecuencias",title="Número de Cilindros") + theme_dark()
```
### Histograma
```{r}
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)
hist(distancia, prob = TRUE, main = "Histograma de densidad", # Densidad
ylab = "Densidad")
```
### Diagrama Sectores
```{r}
count <- c(7, 25, 16, 12, 10, 30)
pie(count, labels = c("0-15", "16-30", "31-45", "46-60", "61-75", "76-90"))
```