Character vectors
As in the previous question, we are going to create a vector. Only this time, we learn to create character vectors. The main difference is that these have to be written as strings and so the names are enclosed within double quotes.
A character vector would look something like this:
food <- c("pizza", "burgers", "salads", "cheese", "pasta")
This exercise is part of the course
Data Science R Basics
Exercise instructions
The temperatures we stored in temp
are from the cities Beijing, Lagos, Paris, Rio de Janeiro, San Juan, and Toronto.
- Create a vector with these city names and call the object
city
. Make sure to use the correct order, spelling and capitalization! - (Also note that DataCamp is not compatible with the punctuation used on an iPad or some mobile phones. Complete DataCamp exercises on a full-size computer to avoid correct answer rejections.)
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# here is an example of how to create a character vector
food <- c("pizza", "burgers", "salads", "cheese", "pasta")
# Create a character vector called city to store the city names
# Make sure to follow the same order as in the instructions