I have a dataframe called dF with two columns: Name, Region. For instance,
Name Region
a EU
a EU
b AM
C AP
... ...
If I do table(d
Example:
result <- table(state.division, state.region) #Sample data
result #will return data like shown below
state.region
state.division Northeast South North Central West
New England 6 0 0 0
Middle Atlantic 3 0 0 0
South Atlantic 0 8 0 0
East South Central 0 4 0 0
West South Central 0 4 0 0
East North Central 0 0 5 0
West North Central 0 0 7 0
Mountain 0 0 0 8
Pacific 0 0 0 5
sum(result[,2]==4) #to count 4's in second column
So in your case you need to store the resulting table to a variable, and the following should do it:
result <- table(dF)
sum(result[,2]==3)