Stacked and Group bar charts in R

 library(vcd)

counts<-table(Arthritis$Improved,Arthritis$Treatment)
counts
barplot(counts,main="Stacked Bar Chart",xlab="Treatment",ylab="Frequency",
        col=c("red","yellow","green"),
        legend=rownames(counts))

library(vcd)
counts<-table(Arthritis$Improved,Arthritis$Treatment)
counts
barplot(counts,main="Grouped Bar Chart",xlab="Treatment",ylab="Frequency",
        col=c("red","yellow","green"),
        legend=rownames(counts),beside=TRUE)

Post a Comment (0)
Previous Post Next Post