---
title: "Bar Charts"
date: "`r Sys.time()`"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
theme: journal
social: menu
source: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(lattice)
library(RColorBrewer)
```
##
### barplot()
```{r barplot,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)
```
### ggplot2
```{r ggplot2,fig.align='center'}
ggplot(mtcars,aes(cyl)) + geom_bar(fill=colores) + labs(x="Cillindros",y="Frecuencias",title="Número de Cilindros") + theme_dark()
```
##
### lattice
```{r lattice,fig.align='center'}
barchart(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores,horizontal=FALSE)
```
### cyl_gear
```{r}
par(mfrow=c(1,2))
x <- table(mtcars$cyl)
colores <- c("orange","blue","purple")
barplot(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores)
y <- table(mtcars$gear)
barplot(y,xlab="Engranajes",ylab="Frecuencias",main="Número de Engranajes",col=rainbow(3))
```
### mtcars_gear
```{r gear,fig.align='center'}
y <- table(mtcars$gear)
barplot(y,xlab="Engranajes",ylab="Frecuencias",main="Número de Engranajes",col=rainbow(3))
```