Dataframes: What's a data frame?
You may remember the matrix, a multi-dimensional object that we discussed earlier. All the elements that you put in a matrix should be of the same type. However, when performing a market research survey, you often have questions such as:
- 'Are your married?' or 'yes/no' questions (= boolean data type)
- 'How old are you?' (= numeric data type)
- 'What is your opinion on this product?' or other 'open-ended' questions (= character data type)
The output, namely the respondents' answers to the questions formulated above, is a data set of different data types. You will often find yourself working with data sets that contain different data types instead of only one. A data frame has the variables of a data set as columns and the observations as rows. This will be a familiar concept for those coming from different statistical software packages such as SAS or SPSS.
This exercise is part of the course
Basic Statistics
Exercise instructions
- print the object mtcars to the console.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# print mtcars to the console