Have a look at the structure
Another method that is often used to get a rapid overview of your data is the function str()
. The function str()
shows you the structure of your dataset. For a data frame it tells you:
- The total number of observations (e.g. 32 car types)
- The total number of variables (e.g. 11 car features)
- A full list of the variables names (e.g.
mpg
,cyl
… ) - The data type of each variable (e.g.
num
) - The first observations
Applying the str()
] function will often be the first thing that you do when receiving a new dataset or data frame. It is a great way to get more insight in your dataset before diving into the real analysis.
This is a part of the course
“Introduction to R”
Exercise instructions
Investigate the structure of mtcars
. Make sure that you see the same numbers, variables and data types as mentioned above.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Investigate the structure of mtcars