The function table
takes a vector and returns the frequency of
each element.
# The "c" in `c()` is short for "concatenate," which is the action of connecting items into a chain
# The function `c()` connects all of the strings within it into a single vector, which we can assign to `x`
x <- c("a", "a", "b", "b", "b", "c")
# Here is an example of what the table function does
table(x)
#> x
#> a b c
#> 2 3 1
You can quickly see how many states are in each region by applying this function. Use this function in one line of code to create a table of states per region.
NOTE
Do not forget to first load the data as in the previous exercises!