Diagramas de Barras

Pie Charts

---
title: "Bar Charts"
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)
```


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

##


### {data-width=7}

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


### {data-width=5}

```{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()

```


##

###

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

###

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

```


###

```{r}
y <- table(mtcars$gear)

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



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

##


###

```{r}
count <- c(7, 25, 16, 12, 10, 30)

pie(count)
```


###

```{r}
count <- c(7, 25, 16, 12, 10, 30)

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

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


###

```{r}


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

pie(count, labels = count, col = color)
```


##


### {data-width=8}

```{r}
par(mfrow = c(1, 3))

pie(count, labels = count, col = 1:6, cex = 2)
pie(count, labels = count, col = rainbow(6), cex = 2)
pie(count, labels = count, col = topo.colors(6), cex = 2)
```



### {data-width=4}
```{r}
pie(count, labels = c("0-15", "16-30", "31-45", "46-60", "61-75", "76-90"))
```