Diagramas de Barras

Column

barplot()

Column

ggplot2

Column

lattice

barplot()

Column

La función barplot() nos permite crear diagramas de barras (Bar Charts) en el lenguaje de programación R.

Pie Chart

Column

El diagrama de sectores (Pie Chart) nos permite representar la distribución de frecuencias de variables cualitativas

All Together

barplot()

ggplot2

lattice

Pie Chart

---
title: "Bar Charts"
date: "`r Sys.Date()`"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed
    social: menu
    theme: united
---

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

library(ggplot2)

library(lattice)

library(RColorBrewer)

```


# Diagramas de Barras  {data-icon="fa-chart-bar"}

Column {data-width=333}
-----------------------------------------------------------------------

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

Column {data-width=333}
-----------------------------------------------------------------------

### ggplot2

```{r ggplot2,fig.align='center'}
ggplot(mtcars,aes(cyl)) + geom_bar(fill=colores) + labs(x="Cilindros",y="Frecuencias",title="Número de Cilindros") + theme_dark()
```

Column {data-width=334}
-----------------------------------------------------------------------


### lattice

```{r lattice,fig.align='center'}
barchart(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores,horizontal = FALSE)
```

# barplot() {data-icon="fa-chart-bar"}

Column {data-width=1000}
-----------------------------------------------------------------------

La función `barplot()` nos permite crear diagramas de barras (**Bar Charts**) en el lenguaje de programación R.

```{r barplot_01,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)
```


# Pie Chart {data-icon="fa-chart-pie"}

Column {data-width=1000}
-----------------------------------------------------------------------

El diagrama de sectores (**Pie Chart**) nos permite representar la distribución de frecuencias de variables cualitativas

```{r pie_chart,fig.align='center'}
count <- c(7, 25, 16, 12, 10, 30)

color <- brewer.pal(length(count), "Set2")

pie(count, labels = count, col = color, density = 50, angle = 45)
```



# All Together {data-icon="fa-chart-bar"}

## {.tabset}

### barplot()


```{r barplot_02,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_01,fig.align='center'}
ggplot(mtcars,aes(cyl)) + geom_bar(fill=colores) + labs(x="Cilindros",y="Frecuencias",title="Número de Cilindros") + theme_dark()
```



### lattice

```{r lattice_01,fig.align='center'}
barchart(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores,horizontal = FALSE)
```


### Pie Chart

```{r pie_chart_01,fig.align='center'}
count <- c(7, 25, 16, 12, 10, 30)

color <- brewer.pal(length(count), "Set2")

pie(count, labels = count, col = color, density = 50, angle = 45)
```