1. Use the function c
to create a vector with the average high
temperatures in January for Beijing, Lagos, Paris, Rio de Janeiro, San
Juan, and Toronto, which are 35, 88, 42, 84, 81, and 30 degrees
Fahrenheit. Call the object temp
.
2. Now create a vector with the city names and call the object city
.
3. Create an object which has the same temperatures as temp and has the city names as names. Use the names
function (tip: run ?names
in RStudio for more information on how to use the function) and the objects defined in the previous
exercises (steps 1 and 2) to associate the temperature data with its corresponding city.
Call the object named_temp
4. Use the [
and :
operators to access the temperature of the first
three cities on the named_temp list. put your result in an object named temp_13
5. Use the [
operator to access the temperature of Paris and San
Juan on the named_temp list. put your result in an object named temp_ps
NOTE
Make sure you add the elements in the same order as in this description!