Quick, have a look at your dataset
Wow, that is a lot of cars!
Working with large datasets is not uncommon in data analysis. When you work with (extremely) large datasets and data frames, your first task as a data analyst is to develop a clear understanding of its structure and main elements. Therefore, it is often useful to show only a small part of the entire dataset.
So how to do this in R? Well, the function head()
enables you to show the first observations of a data frame. Similarly, the function tail()
prints out the last observations in your dataset.
Both head()
and tail()
print a top line called the 'header', which contains the names of the different variables in your dataset.
This exercise is part of the course
Introduction to R
Exercise instructions
Call head()
on the mtcars
dataset to have a look at the header and the first observations.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Call head() on mtcars