Naming a vector in R | Question 1
As a data analyst, it is important to have a clear view on the data that you are using. Understanding what each element refers to is therefore essential.
You can give a name to the elements of a vector with the names()function. Have a look at this example:
some_vector <- c("John Doe", "poker player")
names(some_vector) <- c("Name", "Profession")
This code first creates a vector some_vector and then gives the two elements a name. The first element is assigned the name Name, while the second element is labeled Profession. Printing the contents to the console yields following output:
Name Profession
"John Doe" "poker player"
- The code on the right names the elements in
poker_vectorwith the days of the week. Add code to do the same thing forroulette_vector.