Please download the answer file and edit it on Rstudio. Write your student number in the correct place at the beginning of the answer file. When you finish, send the answers.R file to the answers’ mailbox. All questions are independent and can be answered in any order.

  1. Download the file midterm.txt, store it in your computer, and read it into a data frame called world. Show summary(world).
##                 country         region        area            population       
##  Afghanistan        :  1   africa  :51   Min.   :     300   Min.   :9.280e+04  
##  Albania            :  1   americas:32   1st Qu.:   29100   1st Qu.:2.452e+06  
##  Algeria            :  1   asia    :51   Median :  147500   Median :8.620e+06  
##  Angola             :  1   europe  :44   Mean   :  742092   Mean   :3.984e+07  
##  Antigua_and_Barbuda:  1                 3rd Qu.:  572250   3rd Qu.:2.928e+07  
##  Argentina          :  1                 Max.   :17100000   Max.   :1.380e+09  
##  (Other)            :172                                                       
##      income      
##  Min.   :   598  
##  1st Qu.:  3572  
##  Median : 10650  
##  Mean   : 17124  
##  3rd Qu.: 23500  
##  Max.   :123000  
## 
# write here
  1. Show the first 20 lines of world in a nice way, using the kable command. There may be some warnings, but they are not important.
country region area population income
Afghanistan asia 653000 3.17e+07 1810
Albania europe 28800 2.92e+06 10500
Algeria africa 2380000 3.83e+07 13300
Angola africa 1250000 2.60e+07 6190
Antigua_and_Barbuda americas 440 9.78e+04 18900
Argentina americas 2780000 4.25e+07 19500
Armenia europe 29700 2.89e+06 7730
Australia asia 7740000 2.32e+07 42900
Austria europe 83900 8.58e+06 44200
Azerbaijan europe 86600 9.39e+06 16600
Bahamas americas 13900 3.77e+05 22700
Bahrain asia 770 1.32e+06 43200
Bangladesh asia 148000 1.58e+08 2840
Barbados americas 430 2.83e+05 15300
Belarus europe 208000 9.48e+06 17700
Belgium europe 30500 1.12e+07 40800
Belize americas 23000 3.44e+05 7900
Benin africa 115000 1.00e+07 1940
Bhutan asia 38400 7.65e+05 7070
Bolivia americas 1100000 1.04e+07 6090
# write here
  1. Draw this
# write here

  1. Draw this
# write here

  1. Draw this
# write here

  1. The last graphic is hard to read, since most of the countries have small income and small population. We can see better using the option log="xy". Redraw the last plot using the new option.
# write here

  1. This time the symbol color depends on the region
# write here

  1. Now we want to change the symbol size depending on the country’s area. The formula for the symbol size should be 3*sqrt(area/max(area)))
# write here

  1. Now we will add decoration. Repeat the previous command, and then use the commands legend() and title() to produce this image
# write here