BarCharts_01

barplot()

ggplot2

lattice

mtcars_cyl_gear

mtcars_gear

---
title: "Bar Charts"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    social: menu
    source: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
```

# BarCharts_01 {data-icon="fa-chart-bar"}

##

### 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)

# barplot() es una función base del lenguaje de programación R
```

### ggplot2

```{r ggplot,fig.align='center',class.source="bg-danger", class.output="bg-warning"}

library(ggplot2)

ggplot(mtcars,aes(cyl)) + geom_bar(fill=colores) + labs(x="Cilindros",y="Frecuencias",title="Número de Cilindros") + theme_dark()

```

##

### lattice

```{r lattice,fig.align='center'}

library(lattice)

barchart(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores,horizontal = FALSE)

```

### mtcars_cyl_gear

```{r mtcars_cyl_gear,fig.align='center'}
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 mtcars_gear,fig.align='center'}
y <- table(mtcars$gear)

barplot(y,xlab="Engranajes",ylab="Frecuencias",main="Número de Engranajes",col=rainbow(3))
```