Get startedGet started for free

Exercise 4. Tables

One of the useful outputs of data visualization is that we can learn about the distribution of variables. For categorical data we can construct this distribution by simply computing the frequency of each unique value. This can be done with the function table. Here is an example:

x <- c(3, 3, 3, 3, 4, 4, 2)
table(x)

This exercise is part of the course

Data Science Visualization - Module 2

View Course

Exercise instructions

Use the table function to compute the frequencies of each unique height value. Because we are using the resulting frequency table in a later exercise we want you to save the results into an object and call it tab.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

library(dslabs)
data(heights)
x <- heights$height
Edit and Run Code