Social Media Research

02 R Data Analysis


Question

What can the table() function be used for ?


Answer

table() is useful for calculating the (conditional) frequency of data in a list (or anything else that can be interpreted as factors).

> df
     type
1    male
2  female
3   other
4    male
5    male
6  female
7   other
8  female
9  female
10  other
> table(df$type)

female   male  other 
     4      3      3 

> table(df$type != 'male')

FALSE  TRUE 
    3     7 



Comments