0

I've recently discovered deducer and it's contingency table function (see Exporting deducer's contingency tables as csv or xls)

What I'm trying to do is plot the values from a contingency table in ggplot to show a barplot with % frequency up the y-axis and categorical data along the x-axis. Then if possible I'd like to produce error bars to show the confidence interval for the proportion of each variable from the whole.

For examples using the mtcars data, R produces this using the contingency.tables function:

    table_gears<-contingency.tables(
    row.vars=d(cyl),
    col.vars=d(gear),data=mtcars)
print(table_gears,prop.r=T,prop.c=T,prop.t=F)

Basically the proportion of cars with x gears and y cylinders calculated over both row totals and column totals.

Does anyone no of a way of producing this using ddply or similar and adding in the standards error/confidence interval of these proportions too? I am really struggling and would be really grateful for a lifeline!

Community
  • 1
  • 1
marty_c
  • 5,779
  • 5
  • 24
  • 27
  • Have you tried the ggplot2 documentation? http://docs.ggplot2.org/current/geom_bar.html and http://docs.ggplot2.org/current/geom_errorbar.html give you a barplot and the confidence intervals. – Roman Luštrik Jul 27 '13 at 06:56
  • i have read this documentation, but I need to summarise my data first, as I'd quite like to have summary data tables showing the counts, and proportions and because as far as I can tell geom_errorbar won't calculate the frequency of proportions. cheers – marty_c Jul 27 '13 at 07:55
  • Link now broken, a good reason to have answers on-site. –  Oct 18 '17 at 08:57

0 Answers0