i am trying to plot this data in R -
column1 column2 column3
1-2 abc 10
1-2 def 15
1-2 ghi 20
2-3 abc 80
2-3 def 95
2-3 ghi 10
3-4 abc 30
3-4 def 55
3-4 ghi 80
the x axis would be column1 (so 1-2, 2-3 and 3-4 would be present as the x axis), and on y axis, the values in column3 should be plotted for each of the column2 elements. So this would be a "grouped" barchart essentially.
I am not able to plot this grouped bar chart using R. The code snippet I am using is below:
dataset <- fetch(rs,n=-1)
plot_var <- table(dataset$percentage, dataset$age)
barplot(plot_var, names.arg,
main="Title of Graph",
xlab="Column1", col=c("darkblue","red"),
legend = rownames(plot_var), beside=TRUE)
How do I get this grouped bar chart to display? Thanks!