Diagramas de barras

Column

Barplot()

Column

ggplot2

Column

lattice

Barplot()

Column

La funcion barplot() nos permite crear diagramas de barras(Bar charts) en el lenguaje de programacion R.

Pie chart

Column

El diagrama de sectores (Pie Chart) nos permite representar la distribucion 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'} 
# r barplot, el nombre es barplot
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 funcion `barplot()` nos permite crear diagramas de barras(**Bar charts**) en el lenguaje de programacion 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 distribucion 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_001, fig.align='center'} 
# r barplot, el nombre es barplot
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_001, 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_001, fig.align='center'}
barchart(x,xlab="Cilindros",ylab="Frecuencias",main="Número de Cilindros",col=colores,horizontal = FALSE)
```

### Pie chart

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