c
to create a vector with the average high temperatures stated in the table below. Call the object temp
, do the same for the city names from the table, call this object city
.
city | temperature |
---|---|
Beijing | 35 |
Lagos | 88 |
Paris | 42 |
Rio de Janeiro | 84 |
San Juan | 81 |
Toronto | 30 |
To avoid typo’s
You can copy paste the cities and temperatures from here
cities:"Beijing", "Lagos", "Paris", "Rio de Janeiro", "San Juan", "Toronto"
temperatures:35, 88, 42, 84, 81, 30
Use the names
function and the objects from question 1 to name the temp
vector in a way that every temperature is associated with its corresponding city name.
Hint
run
?names
in RStudio for more information on how to use the function.
Use the [
and :
operators to access the temperature of the first
three cities of the named temp
vector. put your result in an object named temp_13
.
[
operator and a vector to access the temperature of Paris
and San Juan
of the named temp
vector. put your result in an object named temp_ps
.NOTE
Make sure you add the city
and temperature
elements in the same order as in this description!