Here is an easy way to count in R
In normal SQL you can easily do the following to get the count of a particular item
eg. Select count(*) from myTable group by FacilityName”
this statement in SQL will give you the count of the records belonging to each FacilityName.
Here is the R equivalent code
I prefer to use a package called plyr
Let us use the built in dataset in r called as mtcars
install.packages('plyr') library(plyr) count(mtcars,'gear')
It will give you the count as shown below.
gear freq
1 3 15
2 4 12
3 5 5