Rscript -e 'df <- read.csv("data.csv"); print(table(df$dept))'

Category: Data Science & Analysis

Rscript -e 'df <- read.csv("data.csv"); print(table(df$dept))'

Count rows per department with table

table() builds a frequency table from a factor or vector, counting how many rows each department has. The output is a named count per category, sorted by name. This is base R's quick category census, equivalent to xsv frequency. Pass two vectors to table() to build a cross-tabulation of combinations.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.