0

I have a dataFrame that looks like this:

 Name  |  Price   |  City
  ABC  | 10       | Chicago
  XYZ  | 12       | NJ
  ASD  | 43       | Chicago
  RTY  | 34       | Chicago

I want to count the number of occurrences of each City

City    | Count
Chicago | 3
NJ      | 1

How do I do this?

Rakesh Adhikesavan
  • 11,966
  • 18
  • 51
  • 76

1 Answers1

1

Try

aggregate(dataFrame, list(dataFrame$City), FUN=length)
Charles Stangor
  • 292
  • 7
  • 21