barplot()
In this page:
barplot()
barplot(heights) draws a bar chart from a vector of values (or a table() result), one bar per value, useful for comparing categorical counts or totals. names.arg labels each bar. It's the standard way to visualize categorical/count data, as opposed to hist() which is for continuous numeric distributions.
Note: barplot(table(x)) is a common combo: tabulate a categorical vector, then chart the counts directly.
Example: barplot()
sales <- c(Jan = 100, Feb = 150, Mar = 120)
print(sales)
cat("barplot(sales) would draw one bar per month with these heights\n")
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: