Andy Davies
Andy Davies

Reputation: 5824

Transforming table to format for stacked bar chart

I've got a data frame in R that looks like this

URL                 TTFB    StartRender     FullyLoaded  
http://news.bbc.co.uk/      500 750     3000

and I want to plot a stacked bar chart from it where each segment of the bar is as follows:

TTFB  
StartRender - TTFB  
FullyLoaded - StartRender

I'm having a real problem understanding how I need to transform the data to be able to plot the column for each URL (or even what the data needs to look like)

Upvotes: 0

Views: 169

Answers (2)

dmartin
dmartin

Reputation: 653

Faceting provides a good alternative to stacking, and can be done fairly easily in R using ggplot2

Upvotes: 0

Peter Flom
Peter Flom

Reputation: 2388

Stacked bar charts are not good data visualizations. Much better to use a grouped Cleveland dot plot. In R these are available with the dotchart command in the graphics package.

The problem with stacked bar charts is that it is hard to estimate the proportions except for the bottom of the stack.

Upvotes: 1

Related Questions