The data table WorldCities
(in the DCF
package) identifies cities around the world that have large populations or are large for their region.
## total
## 1 2592396767
How many cities larger than 100,000? Larger than 1,000,000?
size
aesthetic.Use transparency, called alpha
, to handle overplotting. Alpha can run from zero to one: zero is completely transparent (a.k.a. invisible); one is completely opaque. You will be setting alpha
the same for every city. Recall that in ggplot
graphics, variables are mapped to aesthetics using the aes()
function. In contrast, aesthetic properties that are the same for every case are set outside the aes()
function. In a typical use, the ggplot()
command will look like
ggplot( data=???, aes( x=???, y=??? ))
The layers of the plot will be used like this:
geom_point( alpha=???, aes( size=??? ) )
where, of course, you will replace the ???
with appropriate variables or constants or data tables.
When you have your plotting commands complete, use those commands to make another graphic, but add this expression to govern the size
attribute: + scale_size_area()
. This will make the area of the dot proportional to the value of the variable mapped to it. Without scale_size_area()
, the diameter of the dot is proportional to the variable. Explain which scale, area or diameter, you think is most informative. (Include both graphics in your Rmd file along with your explanation.)
Create a data table BiggestByCountry
that has the one biggest city in each country.
Plot the locations of BiggestByCountry
as another layer in your graphic. Make them red.
Add to the graphic the names of the cities from BiggestByCountry
. Hint: use geom_text()
. Set the size=2
. Remember, setting is different from mapping a variable. You’ll use the label=
aesthetic to represent the city names.
Find the countries where the biggest city is more than 5M people
The resulting table will have a couple of dozen cases. Display as output in your report all the cases but just these variables: city name, country, and population.Remember, “aesthetic” is being used in its original sense: how things are perceived.↩