lu
lu

Reputation:

How to plot a stacked column graph in R?

does anyone know how to use R to plot a histogram with the columns stacked up by more than 1 variables? Like the "stacked column" graph in excel.

Thank you!

Upvotes: 3

Views: 8100

Answers (3)

Ryogi
Ryogi

Reputation: 5617

There is also barplot.xts in the xtsExtra package.

Upvotes: 1

Ira Cooke
Ira Cooke

Reputation: 1345

For example;

ht1=c(0.3,0.7)
ht2=c(0.4,0.6)
barplot(cbind(ht1,ht2))

Upvotes: 4

Rob Hyndman
Rob Hyndman

Reputation: 31800

I'm assuming you really want a bar chart rather than a histogram. In that case, barplot from standard graphics or barchart from the lattice package will both do it. Or use ggplot as shown in this example or here

Upvotes: 5

Related Questions