In this section,
aggregate() will be covered. They are basic processing functions that come in the base package.
table(): This creates a contingency table with the specified vectors. Although its output is of the table type, it works similar to an array:
sample.data <-data.frame(var1 =rep(c("Male","Female"),10), var2 =rep(c("A","B","C","D"))) example.table<-table(sample.data$var1, sample.data$var2) example.table ## ## A B C D ## Female 0 5 0 5 ## Male 5 0 5 0 example.table[2,2] ##  0
The output of
table() can be indexed in the same way as an array.
aggregate(): This performs one or more functions over a vector split by a factor variable.
aggregate()has basically two ways of usage: