Category Archives: R Barplot

Barplot in R – some variations

Use the commands (to get side by side bar charts for two vectors in R; note how to get the labels for each chart and also how to print vector values over the bars)

x barplot(height,beside=T,main=”Cluster Distributions”,xlab=”Clusters”, ylab=”Percentages”, names=labels,col=c(“violet”,”beige”))

# Draw the bar values above the bars

> text(mp, height, labels = format(height, 4), pos = 3, cex = .75, col=c(“blue”,”red”))

Check what happens when beside=T is removed. After the first iteration, it became clear that i have to seperate out the first cluster (all people who do not have chronic disease), the rest of the clusters are all who have chronic diseases and co-morbid disease combinations.