ggplot2 - Stacked bar plot in r with summarized data -


i'm new r. im trying make stacked bar plot. make work using barplot function. not work out how make legend nice. i'm trying use ggplot2 cant make chart correctly.

the data represents simulation comparing bootstrap confidence interval against standard parametric confidence interval based on t-distribution. data summarized. how data.frame like:

       test    cr type2 1 bootstrap 0.406 0.596 2    t-test 0.382 0.618 

cr = correct rejection, type2 = type 2 errors

what want make stacked bar chart 1 bar each test. bars should stacked cr , type2 height should both summarize 1.

any help/suggestions appreciated!

espen

you should reshape data long format,

library(ggplot2)  d <- read.table(textconnection("test    cr type2 bootstrap 0.406 0.596 t-test 0.382 0.618"),head=true)  library(reshape2)  ggplot(melt(d, id="test"), aes(test, value, fill=variable)) +   geom_bar(stat="identity", position="stack")  

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -