Bar Charts are used to display a single categorical variable.
# Data comes from the mtcars dataset.
barplot(table(mtcars$gear), col="purple", xlab="Number of Gears", ylab="Number of Cars", main="Cars by Gears")
# Data entered in by hand
Company <- c("Garmin", "Magellin", "Mio", "Other", "TomTom");
Percent <- c(47, 17, 7, 10, 19);
barplot(height=Percent, names.arg=Company, col="blue", xlab="Company", ylab="Percentage", main="Market Share of GPS" )
Company <- c("Garmin", "Magellin", "Mio", "Other", "TomTom");
Percent <- c(47, 17, 7, 10, 19);
barplot(height=Percent, col=rainbow(length(Company)), xlab="", ylab="Percentage", main="Market Share of GPS")
legend("topright",legend=Company, fill=rainbow(length(Company)), box.lty=0)
Mathematicss, Computer Science, and Statistics Department Gustavus Adolphus College