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
  • 10,627
  • 16
  • 49
  • 71

1 Answers1

1

Try

aggregate(dataFrame, list(dataFrame$City), FUN=length)
Charles Stangor
  • 294
  • 6
  • 20