I've got this data:
No Yes
Female 411 130
Male 435 124
which was created using the standard table command. Now with plot I can plot this as such:
plot(table(df$gender, df$fraud))
and it then outputs a 2x2 bar chart.
So my question is, how can I do this with ggplot2? Is there any way with out transforming the table-object to a data frame? I would do that, but it becomes a mess and you then need to rename column and row headers and it just becomes a mess for what is really a quite simple thing?
ggplot2 works with data frame, so, you have to convert table into a frame. Here is a sample code:
Now, you can use myFrame in ggplot2:
see Coerce to a Data Frame for more information.
Something such as
gets a similar chart with a minimum amount of relabelling.