Giter Site home page Giter Site logo

rdataviz's Introduction

Data Visualization with R and ggplot2

This github repository contains the materials and slides that I prepared for the 2-hour workshop on data visualization with R and ggplot2 organized by the NYU Politics Data Lab in October 2013.

The purpose of the workshop was to introduce ggplot2 as a tool that allows researchers in the social sciences to easily create elegant and effective graphs.

It was structured in two parts. First, the R scripts 01_ggplot_basics.R and 02_scales_axes_legends.R introduce the grammar of graphics using an analysis of public Facebook posts about the government shutdown (captured using my Rfacebook package for R) as a running example.

The second part of the workshop focused on specific applications on the social sciences. 03_line_plots.R, for example, generates a figure showing the evolution of the unemployment rate in the U.S., similar to the plot on pages 85-97 of the ggplot2 book. 04_coefficients_plots.R shows how to produce regression coefficient plots with confidence intervals, on ggplot2. The resulting figure, shown below, analyzes the effects of different variables about the author and content of public Facebook posts about the shutdown on their popularity.

ggplot2 can also an excellent tool to visualize networks. Using another function from my Rfacebook package, it's easy to show how personal networks on Facebook are clustered on communities that overlap with offline behavior (see 05_networks.R).

Many research articles on the social science rely on maps to visualize geographical information. These maps can also be easily created with ggplot2. Below are two examples that I covered on the workshop: one is a map of Europe with geolocated tweets captured using streamR and colored by language; the other is a map of the U.S. comparing the number of tweets mentioning 'shutdown' and 'obamacare' on October 1st, normalized by population. The code to create these plots can be found on 06_maps.R.

A final example (07_animated_plots.R) features a comparison of different Bayesian sampling algorithms applied to an item-response theory model (see sampling_algorithms.R for the code that I prepared to implement them). Using ImageMagick or ffmpeg, it's possible to create animated plots that illustrate the different speeds of convergence.

rdataviz's People

Contributors

pablobarbera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.