Session Ready
Exercise

Turning info into knowledge - Categorical data

Another type of data you can analyze is categorical data. For this type of variable it makes more sense to look at absolute or relative frequency.

The function table() counts the number of times each kind of category occurs in a variable. For example, to see the number of people who have smoked at least 100 cigarettes in their lifetime, try table(cdc$smoke100) in the console.

You can also get the relative frequencies by dividing the table by the amount of observations in your data frame.

Instructions
100 XP
  • Use the table() function to create the frequency table for genhlth.
  • Now create the relative frequency table for the same variable.