<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/automated-dashboard-visualizations-with-distribution-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://datascienceplus.com/automated-dashboard-visualizations-with-distribution-in-r/"> R Programming – DataScience+</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<ul></ul>
<p><strong>
<p>Categories</p>
<p></p></strong>
<ol>
<li><a rel="nofollow" href="https://datascienceplus.com/category/programming/" title="Permanent Link toProgramming" target="_blank">Programming</a></li>
</ol>
<p><strong>
<p>Tags</p>
<p></p></strong>
<ol>
<li><a rel="nofollow" href="https://datascienceplus.com/tag/data-visualisation/" title="Permanent Link toData Visualisation" target="_blank">Data Visualisation</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/tag/r-markdown/" title="Permanent Link toR Markdown" target="_blank">R Markdown</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/tag/rstats/" title="Permanent Link toR Programming" target="_blank">R Programming</a></li>
</ol>
<p>In this article, you learn how to make Automated Dashboard visualizations with distribution in R. First you need to install the `rmarkdown` package into your R library. Assuming that you installed the `rmarkdown`, next you create a new `rmarkdown` script in R. </p>
<p>After this you type the following code in order to create a dashboard with <code>rmarkdown</code> and <code>flexdashboard</code>:</p>
<pre>
---
title: &quot;Dashboard visualizations in R: Distrubution&quot;
author: &quot;Kristian Larsen&quot;
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
---

```{r setup, include=FALSE}
library(ggplot2)
library(plotly)
theme_set(theme_classic())
```

Row
-----------------------------------------------------------------------

### Chart A: Histogram with Auto Binning

```{r}
g &lt;- ggplot(mpg, aes(displ)) + scale_fill_brewer(palette = &quot;Spectral&quot;)

g + geom_histogram(aes(fill=class), 
                   binwidth = .1, 
                   col=&quot;black&quot;, 
                   size=.1) +  # change binwidth
  labs(title=&quot;Histogram with Auto Binning&quot;, 
       subtitle=&quot;Engine Displacement across Vehicle Classes&quot;)  
ggplotly(p = ggplot2::last_plot())
```


### Chart B: Histogram with Fixed Bins

```{r}
g + geom_histogram(aes(fill=class), 
                   bins=5, 
                   col=&quot;black&quot;, 
                   size=.1) +   # change number of bins
  labs(title=&quot;Histogram with Fixed Bins&quot;, 
       subtitle=&quot;Engine Displacement across Vehicle Classes&quot;) 
ggplotly(p = ggplot2::last_plot())
ggplotly(p = ggplot2::last_plot())
```

Row
-----------------------------------------------------------------------

### Cart C: Histogram on a Categorical variable

```{r}
library(ggplot2)
theme_set(theme_classic())
g &lt;- ggplot(mpg, aes(manufacturer))
g + geom_bar(aes(fill=class), width = 0.5) + 
  theme(axis.text.x = element_text(angle=65, vjust=0.6)) + 
  labs(title=&quot;Histogram on Categorical Variable&quot;, 
       subtitle=&quot;Manufacturer across Vehicle Classes&quot;) 
ggplotly(p = ggplot2::last_plot())
```

### Cart D: Density plot

```{r}
library(ggplot2)
theme_set(theme_classic())

# Plot
g &lt;- ggplot(mpg, aes(cty))
g + geom_density(aes(fill=factor(cyl)), alpha=0.8) + 
    labs(title=&quot;Density plot&quot;, 
         subtitle=&quot;City Mileage Grouped by Number of cylinders&quot;,
         caption=&quot;Source: mpg&quot;,
         x=&quot;City Mileage&quot;,
         fill=&quot;# Cylinders&quot;)
ggplotly(p = ggplot2::last_plot())
```

Row
-----------------------------------------------------------------------

### Cart E: Box plot

```{r}
library(ggplot2)
theme_set(theme_classic())

# Plot
g &lt;- ggplot(mpg, aes(class, cty))
g + geom_boxplot(varwidth=T, fill=&quot;plum&quot;) + 
    labs(title=&quot;Box plot&quot;, 
         subtitle=&quot;City Mileage grouped by Class of vehicle&quot;,
         caption=&quot;Source: mpg&quot;,
         x=&quot;Class of Vehicle&quot;,
         y=&quot;City Mileage&quot;)
ggplotly(p = ggplot2::last_plot())
```

### Cart F: Box plot

```{r}
library(ggthemes)
g &lt;- ggplot(mpg, aes(class, cty))
g + geom_boxplot(aes(fill=factor(cyl))) + 
  theme(axis.text.x = element_text(angle=65, vjust=0.6)) + 
  labs(title=&quot;Box plot&quot;, 
       subtitle=&quot;City Mileage grouped by Class of vehicle&quot;,
       caption=&quot;Source: mpg&quot;,
       x=&quot;Class of Vehicle&quot;,
       y=&quot;City Mileage&quot;)
ggplotly(p = ggplot2::last_plot())
```

Row
-----------------------------------------------------------------------

### Cart G: Box plot + Dot plot

```{r}
library(ggplot2)
theme_set(theme_bw())

# plot
g &lt;- ggplot(mpg, aes(manufacturer, cty))
g + geom_boxplot() + 
  geom_dotplot(binaxis='y', 
               stackdir='center', 
               dotsize = .5, 
               fill=&quot;red&quot;) +
  theme(axis.text.x = element_text(angle=65, vjust=0.6)) + 
  labs(title=&quot;Box plot + Dot plot&quot;, 
       subtitle=&quot;City Mileage vs Class: Each dot represents 1 row in source data&quot;,
       caption=&quot;Source: mpg&quot;,
       x=&quot;Class of Vehicle&quot;,
       y=&quot;City Mileage&quot;)
ggplotly(p = ggplot2::last_plot())
```

### Cart H: Tufte Boxplot


```{r}
library(ggthemes)
library(ggplot2)
theme_set(theme_tufte())  # from ggthemes

# plot
g &lt;- ggplot(mpg, aes(manufacturer, cty))
g + geom_tufteboxplot() + 
      theme(axis.text.x = element_text(angle=65, vjust=0.6)) + 
      labs(title=&quot;Tufte Styled Boxplot&quot;, 
           subtitle=&quot;City Mileage grouped by Class of vehicle&quot;,
           caption=&quot;Source: mpg&quot;,
           x=&quot;Class of Vehicle&quot;,
           y=&quot;City Mileage&quot;)
```

Row
-----------------------------------------------------------------------

### Cart I: Violin plot

```{r}
library(ggplot2)
theme_set(theme_bw())

# plot
g &lt;- ggplot(mpg, aes(class, cty))
g + geom_violin() + 
  labs(title=&quot;Violin plot&quot;, 
       subtitle=&quot;City Mileage vs Class of vehicle&quot;,
       caption=&quot;Source: mpg&quot;,
       x=&quot;Class of Vehicle&quot;,
       y=&quot;City Mileage&quot;)
ggplotly(p = ggplot2::last_plot())
```

### Cart J: Population Pyramid


```{r}
library(ggplot2)
library(ggthemes)
options(scipen = 999)  # turns of scientific notations like 1e+40

# Read data
email_campaign_funnel &lt;- read.csv(&quot;https://raw.githubusercontent.com/selva86/datasets/master/email_campaign_funnel.csv&quot;)

# X Axis Breaks and Labels 
brks &lt;- seq(-15000000, 15000000, 5000000)
lbls = paste0(as.character(c(seq(15, 0, -5), seq(5, 15, 5))), &quot;m&quot;)

# Plot
ggplot(email_campaign_funnel, aes(x = Stage, y = Users, fill = Gender)) +   # Fill column
                              geom_bar(stat = &quot;identity&quot;, width = .6) +   # draw the bars
                              scale_y_continuous(breaks = brks,   # Breaks
                                                 labels = lbls) + # Labels
                              coord_flip() +  # Flip axes
                              labs(title=&quot;Email Campaign Funnel&quot;) +
                              theme_tufte() +  # Tufte theme from ggfortify
                              theme(plot.title = element_text(hjust = .5), 
                                    axis.ticks = element_blank()) +   # Centre plot title
                              scale_fill_brewer(palette = &quot;Dark2&quot;)  # Color palette
```
</pre>
<p>Screenshot:<br>
<a rel="nofollow" href="https://i1.wp.com/datascienceplus.com/wp-content/uploads/2018/12/V4-Distribution.jpg?ssl=1" target="_blank"><img sizes="(max-width: 490px) 100vw, 490px" src="https://i1.wp.com/datascienceplus.com/wp-content/uploads/2018/12/V4-Distribution-490x166.jpg?w=450&ssl=1" alt="" class="wp-image-18898" data-recalc-dims="1"></a></p>
<p>The result of the above coding are published with RPubs <a rel="nofollow" href="https://rpubs.com/knl84/445854" target="_blank">here</a>.</p>
<h3>References</h3>
<ol>
<li><a rel="nofollow" href="https://rmarkdown.rstudio.com/flexdashboard/" target="_blank">Using flexdashboard in R</a></li>
</ol>
<p><strong>
<p>Related Post</p>
<p></p></strong>
<ol>
<li><a rel="nofollow" href="https://datascienceplus.com/automated-dashboard-visualizations-with-ranking-in-r/" title="Permanent Link toAutomated Dashboard Visualizations with Ranking in R" target="_blank">Automated Dashboard Visualizations with Ranking in R</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/automated-dashboard-visualizations-with-deviation-in-r/" title="Permanent Link toAutomated Dashboard visualizations with Deviation in R" target="_blank">Automated Dashboard visualizations with Deviation in R</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/automated-dashboard-with-various-correlation-visualizations-in-r/" title="Permanent Link toAutomated Dashboard with various correlation visualizations in R" target="_blank">Automated Dashboard with various correlation visualizations in R</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/automated-dashboard-with-visualization-and-regression-for-healthcare-data/" title="Permanent Link toAutomated Dashboard with Visualization and Regression for Healthcare Data" target="_blank">Automated Dashboard with Visualization and Regression for Healthcare Data</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/create-easy-automated-dashbords-with-r-and-markdown/" title="Permanent Link toCreate easy automated dashbords with R and Markdown" target="_blank">Create easy automated dashbords with R and Markdown</a></li>
</ol>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://datascienceplus.com/automated-dashboard-visualizations-with-distribution-in-r/"> R Programming – DataScience+</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/OhQl4-VOXpI" height="1"></a></div>