Giter Club home page Giter Club logo

r_data_viz's Introduction

Data Visualization Using R

R_data_viz

This repository houses R scripts for data visualization. The point of these scripts is not to present meaningful data analyses, but simply to provide examples of common data visualization tools. All scripts are written in R, using tidyverse, ggplot2, and reshape2 libraries.


Box Plots

Code File: ggplot_boxplot.R

Video Tutorial: https://youtu.be/1BMa5X5eruQ

Description: This script provides a simple example of a grouped box plot (goals scored by NHL players during the 2018 season, grouped by position). The tidy portion of the code also provides useful information on subsetting data based on column number and variable-specific filtering, changing column data types within a data.frame, and string location and replacement.

The code also includes a call to geom_jitter(), also grouped by position, which plots individual data points over the boxplots.


Box Plot + Connected Points

Code File: ggplot_point_boxplot_combo.R

Video Tutorial: https://www.youtube.com/watch?v=lIWE_7OS9N4&t=32s

Description: This script provides an example of grouped boxplots and connected points on a single plot. This type of figure can be used, for example, to show group- and individual-level responses to an intervention:


Violin Plots

Code File: ggplot_violin.R

Description: This script provides examples of a grouped violin plots, similar to the box plots above (goals scored by NHL players during the 2018 season, grouped by position). The tidy portion of the code also provides useful information on subsetting data based on column number and variable-specific filtering, changing column data types within a data.frame, and string location and replacement.

The code also includes a call to geom_boxplot(), also grouped by position, which adds box plots to each violin.


Grouped Continuous Line Plot

Code File: ggplot_grouped_continuous_data.R

Data File: data/continuous_grf_curves.xlsx

Video Tutorial: https://www.youtube.com/watch?v=rQZ8u1cbycg&t=1s

Description: This script provides a simple example of a grouped line plot, showing the mean and standrad deviation (as colored ribbons) of a continuous variable for three separate groups. The continuous variable in this example is the anteroposterior ground reaction force captured during a dynamic postural disturbance.


Basic Line Plot

Code File: ggplot_lineplot.R

Description: This script provides a simple example of a line plot (high temperature across days of September in Birmingham, AL). The tidy portion of the code also provides useful information on subsetting data based on column number and variable-specific filtering, and changing column data types within a data.frame.


Scatter Plots

Code File: ggplot_scatterplot.R

Video Tutorial: https://youtu.be/XEgyC1Oz9KQ

Description: This script provides simple examples of scatter plots (goals scored versus time on ice by NHL players). The tidy portion of the code also provides useful information on subsetting data based on column number and variable-specific filtering, changing column data types within a data.frame, and string location and replacement. The script has an example of an ungrouped scatter plot:

The code also includes an example of a grouped scatter plot (grouped by position):

Finally, the code includes a call to geom_smooth(), which adds a best fit line:


2D Density Plots

Code File: ggplot_density2d.R

Video Tutorial: https://youtu.be/_eDzjQXaU9s

Description: This script provides simple examples of filled and unfilled density plots with jittered data overlayed. Here is an example of a filled density plot:


Scatter Plots with Marginal Histograms

Code File: ggplot_marginal_distributions.R

Video Tutorial: https://www.youtube.com/watch?v=NApff-foQn4&feature=youtu.be

Description: This script provides a simple examples of a scatter plot with histograms plotted in the margins. Note that the video tutorial also includes instructions for adding density and box plots to the margins.


Histograms

Code File: ggplot_histogram.R

Video Tutorial: https://youtu.be/Iax_qtK1XxM

Description: This script provides simple examples of histograms (goals scored in a season, across multiple seasons). The tidy portion of the code also provides useful information on subsetting data based on column number and variable-specific filtering, changing column data types within a data.frame, and string location and replacement. The script has an example of an ungrouped histogram:

The code also includes an example of a grouped histogram (grouped by position, forward versus defense). Overlapping distributions can be shown as completely overlapping, dodged, or transparent:

Finally, the code includes a call to geom_density(), which includes a density distribution:


Heat Mapped Correlation Matrix

Code File: ggplot_cormat.R

Video Tutorial: https://youtu.be/W9YMjvlRtCg

Description: This script provides an example of a heat mapped correlation matrix (from a large NHL dataset). The tidy portion of the code also provides useful information on subsetting data based on column number and variable-specific filtering, changing column data types within a data.frame, string location and replacement, and generating a correlation matrix. The script has an example of a simple matrix:

The code also includes an example that plots the correlation coefficient in text over each correlation matrix position:


Ridgeline Plots

Code File: ggplot_ridgeplot.R

Video Tutorial: https://youtu.be/3fuzBLlft9Q

Description: This script provides a simple example of a grouped ridgeline plot (average avocado prices across months in 2019 grouped by month). The tidy portion of the code also provides useful information on subsetting data using variable-specific filtering, changing column data types within a data.frame, string location and replacement, and adding column data using mutate().


Facet Wrapping

Code File: ggplot_facetwrap_histos.R

Description: This script provides examples of facet wrapped histograms (distribution of goals within each NHL team during the 2018 season). The tidy portion of the code also provides useful information on subsetting data based on column number and variable-specific filtering, changing column data types within a data.frame, and string location and replacement. The script has an example of a simple facet wrap:

The code also includes examples with added complexity (grouping by a variable within each team and adding density):

r_data_viz's People

Contributors

dkuhman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.