Variable names
In the previous question, we saw the different variables that are a part of this dataset from the output of the str()
function. The function names()
is specifically designed to extract the column names from a data frame.
This exercise is part of the course
Data Science R Basics
Exercise instructions
For this question, we will use the names()
function to extract the column names of the murders
data frame.
- What are the column names used by the
murders
data frame for the five variables?
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load package and data
library(dslabs)
data(murders)
# Use the function names to extract the variable names