table()
In this page:
table()
table(x) counts how many times each distinct value appears in a vector, producing a frequency table. It's the quickest way to summarize categorical data. Passing two vectors, table(x, y), produces a cross-tabulation counting combinations of both.
Note: table() is the fastest way to check the distribution of values in a categorical column before deeper analysis.
Example: table()
colors <- c("red", "blue", "red", "green", "blue", "red")
print(table(colors))
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: