Livy KMG

Gapminder Exercise

The Gapminder website contains over 500 data sets with information about the world’s population. Your task is to download a data set of your choice and create 2-5 plots that make use of the techniques from Lesson 3.

You might use a simple histogram, a boxplot split over a categorical variable, or a frequency polygon. The choice is yours!

Once you’ve completed your investigation, create a post in the discussions that includes: 1. any questions you answered, your observations, and summary statistics 2. snippets of code that created the plots 3. links to the images of your plots

You can save images by using the ggsave() command. ggsave() will save the last plot created. For example… qplot(x = price, data = diamonds) ggsave(‘priceHistogram.png’)

ggsave currently recognises the extensions eps/ps, tex (pictex), pdf, jpeg, tiff, png, bmp, svg and wmf (windows only).

Copy and paste all of the code that you used for your investigation, and submit it when you are ready.

The following command may be helpful for some of the Gapminder Data sets, once it’s been converted to csv format:

read.csv(‘data.csv’, header = T, row.names = 1, check.names = F).

You may want to look at additional function arguments in the help file for the read.table() family for additional tools that can help you read in data.

If you want to exchange the rows and columns of your dataframe, it will also be useful to know the transpose function, t(). ====================================================================================

Gapminder Data

http://www.gapminder.org/data/ https://docs.google.com/spreadsheets/d/1gJLA2BebcFBf7PBpzz5rhjMHK_or8rJf7PhjiE068YA/pub

Hans Rosling’s 200 Countries, 200 Years, 4 Minutes https://www.youtube.com/watch?v=jbkSRLYSojo

About the data:

Aid recieved % of gni indicator_aid received % of gni Net official development assistance (ODA) consists of disbursements of loans made on concessional terms (net of repayments of principal) and grants by official agencies of the members of the Development Assistance Committee (DAC), by multilateral institutions, and by non-DAC countries to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. It includes loans with a grant element of at least 25 percent (calculated at a rate of discount of 10 percent).

Source organization(s) World Bank
Link to source organization http://data.worldbank.org/indicator Palau This country is not displayed in the graph due to the extremely high percentage of its aid to its GNI

getwd()
## [1] "C:/Users/gk-km/OneDrive/Documents/career_da-pffs/udacity-eda/eda-course-materials/lesson4/gapminder"
setwd("~/career_da-pffs/udacity-eda/eda-course-materials/lesson4")
#Load necesary Libraries
library(readxl, quietly=TRUE)
library(reshape2)
library(plyr)
library(ggplot2)
library(gridExtra)
library(tidyr)
## 
## Attaching package: 'tidyr'
## The following object is masked from 'package:reshape2':
## 
##     smiths
#Read in the data
aid_received <- read_excel('aid_received.xlsx')
#Explore data
names(aid_received)
##  [1] "Aid received % of GNI" "1960"                 
##  [3] "1961"                  "1962"                 
##  [5] "1963"                  "1964"                 
##  [7] "1965"                  "1966"                 
##  [9] "1967"                  "1968"                 
## [11] "1969"                  "1970"                 
## [13] "1971"                  "1972"                 
## [15] "1973"                  "1974"                 
## [17] "1975"                  "1976"                 
## [19] "1977"                  "1978"                 
## [21] "1979"                  "1980"                 
## [23] "1981"                  "1982"                 
## [25] "1983"                  "1984"                 
## [27] "1985"                  "1986"                 
## [29] "1987"                  "1988"                 
## [31] "1989"                  "1990"                 
## [33] "1991"                  "1992"                 
## [35] "1993"                  "1994"                 
## [37] "1995"                  "1996"                 
## [39] "1997"                  "1998"                 
## [41] "1999"                  "2000"                 
## [43] "2001"                  "2002"                 
## [45] "2003"                  "2004"                 
## [47] "2005"                  "2006"                 
## [49] "2007"                  "2008"                 
## [51] "2009"                  "2010"
str(aid_received)
## Classes 'tbl_df', 'tbl' and 'data.frame':    275 obs. of  52 variables:
##  $ Aid received % of GNI: chr  "Abkhazia" "Afghanistan" "Akrotiri and Dhekelia" "Albania" ...
##  $ 1960                 : num  NA 3.13 NA NA 11.02 ...
##  $ 1961                 : num  NA 6.19 NA NA 14.73 ...
##  $ 1962                 : num  NA 3.04 NA NA 18.05 ...
##  $ 1963                 : num  NA 4.78 NA NA 10.2 ...
##  $ 1964                 : num  NA 5.66 NA NA 7.83 ...
##  $ 1965                 : num  NA 5.25 NA NA 4.79 ...
##  $ 1966                 : num  NA 3.52 NA NA 4.35 ...
##  $ 1967                 : num  NA 2.38 NA NA 3.27 ...
##  $ 1968                 : num  NA 2.09 NA NA 3.15 ...
##  $ 1969                 : num  NA 1.9 NA NA 3.08 ...
##  $ 1970                 : num  NA 1.55 NA NA 2.58 ...
##  $ 1971                 : num  NA 2.38 NA NA 2.4 ...
##  $ 1972                 : num  NA 3.38 NA NA 1.64 ...
##  $ 1973                 : num  NA 3.16 NA NA 1.45 ...
##  $ 1974                 : num  NA 2.233 NA NA 0.977 ...
##  $ 1975                 : num  NA 2.87 NA NA 1.49 ...
##  $ 1976                 : num  NA 2.736 NA NA 0.785 ...
##  $ 1977                 : num  NA 2.837 NA NA 0.594 ...
##  $ 1978                 : num  NA 2.448 NA NA 0.703 ...
##  $ 1979                 : num  NA 2.793 NA NA 0.316 ...
##  $ 1980                 : num  NA 0.856 NA NA 0.485 ...
##  $ 1981                 : num  NA 0.645 NA NA 0.388 ...
##  $ 1982                 : num  NA NA NA NA 0.311 ...
##  $ 1983                 : num  NA NA NA NA 0.2 ...
##  $ 1984                 : num  NA NA NA NA 0.233 ...
##  $ 1985                 : num  NA NA NA NA 0.307 ...
##  $ 1986                 : num  NA NA NA NA 0.27 ...
##  $ 1987                 : num  NA NA NA NA 0.329 ...
##  $ 1988                 : num  NA NA NA 0.261 0.301 ...
##  $ 1989                 : num  NA NA NA 0.443 0.294 ...
##  $ 1990                 : num  NA NA NA 0.526 0.553 ...
##  $ 1991                 : num  NA NA NA 29.706 0.485 ...
##  $ 1992                 : num  NA NA NA 60.182 0.812 ...
##  $ 1993                 : num  NA NA NA 22.259 0.673 ...
##  $ 1994                 : num  NA NA NA 8.19 0.72 ...
##  $ 1995                 : num  NA NA NA 7.317 0.743 ...
##  $ 1996                 : num  NA NA NA 7.344 0.687 ...
##  $ 1997                 : num  NA NA NA 7.485 0.539 ...
##  $ 1998                 : num  NA NA NA 9.634 0.909 ...
##  $ 1999                 : num  NA NA NA 13.965 0.297 ...
##  $ 2000                 : num  NA NA NA 8.385 0.383 ...
##  $ 2001                 : num  NA NA NA 6.338 0.371 ...
##  $ 2002                 : num  NA 32.064 NA 6.717 0.346 ...
##  $ 2003                 : num  NA 34.781 NA 6.091 0.365 ...
##  $ 2004                 : num  NA 43.68 NA 3.923 0.388 ...
##  $ 2005                 : num  NA 45.183 NA 3.737 0.356 ...
##  $ 2006                 : num  NA 41.712 NA 3.428 0.213 ...
##  $ 2007                 : num  NA 56.741 NA 2.793 0.294 ...
##  $ 2008                 : num  NA 45.628 NA 2.766 0.192 ...
##  $ 2009                 : num  NA 50.854 NA 2.972 0.228 ...
##  $ 2010                 : num  NA 40.868 NA 2.897 0.128 ...
dim(aid_received)
## [1] 275  52
summary(aid_received)
##  Aid received % of GNI      1960               1961        
##  Length:275            Min.   :-0.48893   Min.   :-0.7450  
##  Class :character      1st Qu.: 0.09117   1st Qu.: 0.3745  
##  Mode  :character      Median : 0.99951   Median : 1.2894  
##                        Mean   : 2.77058   Mean   : 3.5113  
##                        3rd Qu.: 3.66457   3rd Qu.: 4.8038  
##                        Max.   :28.53016   Max.   :31.2760  
##                        NA's   :210        NA's   :207      
##       1962              1963              1964              1965        
##  Min.   :-0.5955   Min.   :-0.1419   Min.   :-0.6139   Min.   :-0.2139  
##  1st Qu.: 0.8249   1st Qu.: 0.8248   1st Qu.: 0.8947   1st Qu.: 1.0834  
##  Median : 1.6421   Median : 1.8424   Median : 2.7254   Median : 2.4318  
##  Mean   : 4.0565   Mean   : 3.4270   Mean   : 4.0288   Mean   : 4.4837  
##  3rd Qu.: 4.7249   3rd Qu.: 4.1890   3rd Qu.: 5.7089   3rd Qu.: 6.2297  
##  Max.   :41.7871   Max.   :17.2680   Max.   :23.1078   Max.   :25.5199  
##  NA's   :207       NA's   :204       NA's   :203       NA's   :198      
##       1966               1967               1968         
##  Min.   :-0.07541   Min.   :-0.07007   Min.   : 0.00045  
##  1st Qu.: 1.17582   1st Qu.: 0.94631   1st Qu.: 1.05250  
##  Median : 2.67667   Median : 2.38379   Median : 3.15479  
##  Mean   : 4.76102   Mean   : 4.60471   Mean   : 4.87291  
##  3rd Qu.: 5.66321   3rd Qu.: 5.99542   3rd Qu.: 6.16950  
##  Max.   :31.38229   Max.   :42.37892   Max.   :34.51436  
##  NA's   :192        NA's   :188        NA's   :186       
##       1969               1970               1971         
##  Min.   : 0.00568   Min.   : 0.00504   Min.   : 0.01628  
##  1st Qu.: 0.96756   1st Qu.: 0.85000   1st Qu.: 0.99658  
##  Median : 2.55219   Median : 2.62268   Median : 2.51710  
##  Mean   : 4.22960   Mean   : 4.15566   Mean   : 4.38114  
##  3rd Qu.: 6.33315   3rd Qu.: 5.73909   3rd Qu.: 6.06545  
##  Max.   :27.00029   Max.   :31.80635   Max.   :35.33910  
##  NA's   :186        NA's   :182        NA's   :182       
##       1972               1973              1974         
##  Min.   : 0.00399   Min.   :-0.0148   Min.   : 0.00315  
##  1st Qu.: 1.12404   1st Qu.: 0.9003   1st Qu.: 0.83989  
##  Median : 2.73359   Median : 2.4741   Median : 2.58276  
##  Mean   : 5.02737   Mean   : 5.0559   Mean   : 6.24655  
##  3rd Qu.: 5.80852   3rd Qu.: 6.9559   3rd Qu.: 9.73486  
##  Max.   :45.32969   Max.   :41.5708   Max.   :52.32022  
##  NA's   :181        NA's   :178       NA's   :178       
##       1975               1976               1977         
##  Min.   :-0.01535   Min.   :-0.02123   Min.   :-0.00054  
##  1st Qu.: 1.03119   1st Qu.: 0.75321   1st Qu.: 0.68560  
##  Median : 2.89663   Median : 2.54928   Median : 3.37624  
##  Mean   : 6.27436   Mean   : 6.10898   Mean   : 6.17797  
##  3rd Qu.: 7.92386   3rd Qu.: 8.50684   3rd Qu.: 8.81144  
##  Max.   :45.06606   Max.   :48.82969   Max.   :47.22268  
##  NA's   :178        NA's   :177        NA's   :173       
##       1978               1979              1980         
##  Min.   :-0.03173   Min.   :-0.1392   Min.   :-0.03975  
##  1st Qu.: 0.86971   1st Qu.: 0.8769   1st Qu.: 0.93112  
##  Median : 4.04824   Median : 3.6267   Median : 4.65926  
##  Mean   : 6.89517   Mean   : 7.3190   Mean   : 8.76088  
##  3rd Qu.: 9.50993   3rd Qu.:10.5730   3rd Qu.:10.39580  
##  Max.   :46.64241   Max.   :46.2533   Max.   :79.63180  
##  NA's   :173        NA's   :170       NA's   :167       
##       1981               1982               1983         
##  Min.   :-0.03098   Min.   :-0.03963   Min.   : 0.00055  
##  1st Qu.: 0.97643   1st Qu.: 0.86093   1st Qu.: 0.77468  
##  Median : 4.64293   Median : 4.60019   Median : 4.56349  
##  Mean   : 8.01527   Mean   : 7.69544   Mean   : 7.49577  
##  3rd Qu.:10.67873   3rd Qu.: 9.73751   3rd Qu.:10.11246  
##  Max.   :55.04959   Max.   :62.17212   Max.   :46.85706  
##  NA's   :165        NA's   :164        NA's   :163       
##       1984               1985               1986         
##  Min.   :-0.04039   Min.   :-0.00946   Min.   :-0.03263  
##  1st Qu.: 0.73691   1st Qu.: 0.77424   1st Qu.: 0.96993  
##  Median : 3.93015   Median : 4.37903   Median : 5.27690  
##  Mean   : 7.46616   Mean   : 7.79665   Mean   : 9.06783  
##  3rd Qu.:10.33156   3rd Qu.:11.00351   3rd Qu.:11.48223  
##  Max.   :47.52077   Max.   :48.11748   Max.   :64.54760  
##  NA's   :162        NA's   :158        NA's   :156       
##       1987               1988              1989              1990         
##  Min.   :-0.07732   Min.   :-0.1338   Min.   :-0.2334   Min.   :-0.00868  
##  1st Qu.: 0.75768   1st Qu.: 0.5745   1st Qu.: 0.5942   1st Qu.: 1.02987  
##  Median : 4.46101   Median : 4.9173   Median : 4.4653   Median : 6.50899  
##  Mean   : 9.37230   Mean   : 8.7453   Mean   : 9.0291   Mean   :10.25150  
##  3rd Qu.:11.51649   3rd Qu.:11.9815   3rd Qu.:13.9451   3rd Qu.:14.74109  
##  Max.   :67.09700   Max.   :65.2736   Max.   :57.2087   Max.   :61.65772  
##  NA's   :154        NA's   :152       NA's   :150       NA's   :148       
##       1991              1992              1993              1994         
##  Min.   :-0.2863   Min.   :-0.2973   Min.   :-0.2645   Min.   : -0.6676  
##  1st Qu.: 1.0621   1st Qu.: 0.7079   1st Qu.: 0.7014   1st Qu.:  0.7180  
##  Median : 5.4927   Median : 4.7030   Median : 4.1226   Median :  5.0412  
##  Mean   : 9.8185   Mean   : 9.7428   Mean   : 8.5139   Mean   : 11.9079  
##  3rd Qu.:13.7929   3rd Qu.:13.1469   3rd Qu.:13.6916   3rd Qu.: 16.4678  
##  Max.   :72.0603   Max.   :81.2903   Max.   :63.2279   Max.   :242.2864  
##  NA's   :148       NA's   :142       NA's   :137       NA's   :133       
##       1995               1996              1997              1998         
##  Min.   : -0.1023   Min.   :-0.4750   Min.   :-0.2537   Min.   :-0.01482  
##  1st Qu.:  0.5191   1st Qu.: 0.6786   1st Qu.: 0.7710   1st Qu.: 0.96546  
##  Median :  4.1157   Median : 4.4857   Median : 4.1296   Median : 4.38994  
##  Mean   : 10.2854   Mean   : 9.0431   Mean   : 7.6481   Mean   : 7.88744  
##  3rd Qu.: 14.8764   3rd Qu.:13.3110   3rd Qu.:10.3815   3rd Qu.:11.00570  
##  Max.   :145.1223   Max.   :71.7857   Max.   :48.9776   Max.   :75.78811  
##  NA's   :132        NA's   :138       NA's   :138       NA's   :138       
##       1999              2000               2001               2002        
##  Min.   :-0.2644   Min.   :-0.02033   Min.   :-0.04673   Min.   :-0.1006  
##  1st Qu.: 0.9713   1st Qu.: 0.81122   1st Qu.: 0.82919   1st Qu.: 0.7972  
##  Median : 4.3348   Median : 3.85039   Median : 3.70999   Median : 5.6681  
##  Mean   : 7.3823   Mean   : 7.92049   Mean   : 8.66956   Mean   : 8.9226  
##  3rd Qu.:10.5391   3rd Qu.:11.31053   3rd Qu.:12.33124   3rd Qu.:12.0212  
##  Max.   :47.5355   Max.   :71.55631   Max.   :69.22282   Max.   :74.7611  
##  NA's   :138       NA's   :140        NA's   :139        NA's   :138      
##       2003              2004              2005               2006        
##  Min.   :-0.6895   Min.   :-2.7012   Min.   :-0.09992   Min.   :-0.1092  
##  1st Qu.: 0.7806   1st Qu.: 0.6649   1st Qu.: 0.55176   1st Qu.: 0.4615  
##  Median : 3.5750   Median : 3.9805   Median : 3.92002   Median : 3.6205  
##  Mean   : 9.0470   Mean   : 8.5303   Mean   : 8.52561   Mean   : 7.5080  
##  3rd Qu.:12.9202   3rd Qu.:12.2642   3rd Qu.:11.22838   3rd Qu.:11.1478  
##  Max.   :99.5132   Max.   :69.1472   Max.   :78.84479   Max.   :57.6217  
##  NA's   :139       NA's   :137       NA's   :135        NA's   :136      
##       2007               2008               2009         
##  Min.   : -0.7303   Min.   : -0.2353   Min.   :-0.03068  
##  1st Qu.:  0.4859   1st Qu.:  0.5021   1st Qu.: 0.53664  
##  Median :  3.5980   Median :  3.3260   Median : 3.85395  
##  Mean   :  7.6592   Mean   :  7.8747   Mean   : 7.56540  
##  3rd Qu.: 10.0495   3rd Qu.:  9.5991   3rd Qu.:10.30059  
##  Max.   :119.9367   Max.   :181.0143   Max.   :50.85367  
##  NA's   :136        NA's   :137        NA's   :137       
##       2010         
##  Min.   : -0.1797  
##  1st Qu.:  0.6659  
##  Median :  3.5271  
##  Mean   :  8.4313  
##  3rd Qu.: 10.4137  
##  Max.   :127.4827  
##  NA's   :141

Data cleaning issues:

  1. gather the years and cases to one column each http://garrettgman.github.io/tidying/
  2. remove missing incomplete cases
  3. correct Column names
### Reshape data - to gather years to year
aid_received2 <- gather(aid_received, "year", "cases", 2:52)
### Remove Missing values
aid_received3 <- aid_received2[complete.cases(aid_received2),]

names(aid_received3)
## [1] "Aid received % of GNI" "year"                  "cases"
### Correct column names 
colnames(aid_received3)[3] <- "donor_aid"
colnames(aid_received3)[1] <- "country"

# Check the column names
colnames(aid_received3)
## [1] "country"   "year"      "donor_aid"
# check the dataset
head(aid_received3)
## # A tibble: 6 x 3
##   country     year  donor_aid
##   <chr>       <chr>     <dbl>
## 1 Afghanistan 1960    3.13   
## 2 Algeria     1960   11.0    
## 3 Bahamas     1960   -0.0267 
## 4 Belize      1960    6.52   
## 5 Benin       1960    0.00887
## 6 Botswana    1960   10.0
#  Summary stats of donor aid
summary(aid_received3$donor_aid)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  -2.7012   0.7621   3.4547   7.5419  10.2523 242.2864
#  Histogram of donor aid
qplot(x = donor_aid, data= aid_received3)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

#  investigating Histogram by binwidth and limiting the axes
p1 <- qplot(x = donor_aid, data= aid_received3, binwidth = 1, ylab = 'p1 % Gni aid' ) + 
scale_x_continuous(lim = c(0,80), breaks = seq(0, 80, 3))

p2 <- qplot(x = donor_aid, data= aid_received3, binwidth = 3, ylab = 'p2 % Gni aid' ) + 
scale_x_continuous(lim = c(0,80), breaks = seq(0, 80, 3))

p3 <- qplot(x = donor_aid, data= aid_received3, binwidth = 5, ylab = 'p3 % Gni aid') +
scale_x_continuous(lim = c(0,80), breaks = seq(0, 80, 2))
grid.arrange(p1, p2, p3, ncol=3)
## Warning: Removed 104 rows containing non-finite values (stat_bin).

## Warning: Removed 104 rows containing non-finite values (stat_bin).
## Warning: Removed 1 rows containing missing values (geom_bar).
## Warning: Removed 104 rows containing non-finite values (stat_bin).

ggsave('histobin_changes.png')
## Saving 7 x 5 in image
## Warning: Removed 104 rows containing non-finite values (stat_bin).

Observations

Decreasing the size of the bin increases the clarity of the plots and decreases the values of the y-axes.

Since the distribution is longtailed to the right, it calls for transformation so that we can see the data clearly without the tails!

# Transormation using log10 and sqrt
# Add a Scaling Layer

p1 <- qplot(x = donor_aid, data= aid_received3, binwidth = 1) 
p2 <- p1 + scale_x_log10()
p3 <- p1 + scale_x_sqrt()

grid.arrange(p1,p2,p3, ncol = 1)
## Warning in self$trans$transform(x): NaNs produced
## Warning: Transformation introduced infinite values in continuous x-axis
## Warning: Removed 96 rows containing non-finite values (stat_bin).
## Warning in self$trans$transform(x): NaNs produced
## Warning: Transformation introduced infinite values in continuous x-axis
## Warning: Removed 96 rows containing non-finite values (stat_bin).

ggsave('histo_transformation.png')
## Saving 7 x 5 in image
## Warning in self$trans$transform(x): NaNs produced
## Warning: Transformation introduced infinite values in continuous x-axis
## Warning: Removed 96 rows containing non-finite values (stat_bin).

Questions

  1. Is faceting possible

  2. Can we apply proportions to this exploration - what does it tell us? = no -coz its one distribution only. Proprortions Work for 2 or more, for comparative purposes.

a Histogram needs a continuous x variable; year and country do not meet this requirement.

Investigate donor aid using a frequency polygon ?

This is Not necessary because such a graph serves to compare two or more distributions at once

How do you interpret the values below?

#Summary stats of donor aid and transformed data

summary(aid_received3$donor_aid)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  -2.7012   0.7621   3.4547   7.5419  10.2523 242.2864
summary(log10(aid_received3$donor_aid + 1))
## Warning in summary(log10(aid_received3$donor_aid + 1)): NaNs produced
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
## -0.5935  0.2464  0.6490  0.6691  1.0513  2.3861       1
summary(sqrt(aid_received3$donor_aid))
## Warning in sqrt(aid_received3$donor_aid): NaNs produced
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 
##  0.00995  0.91669  1.90093  2.21916  3.22202 15.56555       96

?***qplot(x = year, y = donor_aid, data = aid_received3) + geom = ‘boxplot’)

Questions

**1.Boxplot ? how ? do we need to create factor variables? how?

**2. dotplot ? how ? qplot(x = donor_aid, data= aid_received3, geom_dotplot()) + scale_x_continuous(lim = c(0,75)) -Don’t know how to automatically pick scale for object of type -LayerInstance/Layer/ggproto/gg. Defaulting to continuous. -Error: Aesthetics must be either length 1 or the same as the data (5774): x, y

**3. Barplot ? how ? qplot(x = donor_aid, data= aid_received3, geom_bar()) + scale_x_continuous(lim = c(0,75))

***same prob as above

or What is the donor_aid range for the middle 50% of 2010?

#How has donor aid changed over the years
by(aid_received3$donor_aid, aid_received3$year, summary)
## aid_received3$year: 1960
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.48893  0.09117  0.99951  2.77058  3.66457 28.53016 
## -------------------------------------------------------- 
## aid_received3$year: 1961
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.7450  0.3745  1.2894  3.5113  4.8038 31.2760 
## -------------------------------------------------------- 
## aid_received3$year: 1962
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.5955  0.8249  1.6421  4.0565  4.7249 41.7871 
## -------------------------------------------------------- 
## aid_received3$year: 1963
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.1419  0.8249  1.8424  3.4270  4.1890 17.2680 
## -------------------------------------------------------- 
## aid_received3$year: 1964
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.6139  0.8947  2.7254  4.0288  5.7089 23.1078 
## -------------------------------------------------------- 
## aid_received3$year: 1965
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2139  1.0834  2.4318  4.4837  6.2297 25.5199 
## -------------------------------------------------------- 
## aid_received3$year: 1966
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.07541  1.17582  2.67667  4.76102  5.66321 31.38229 
## -------------------------------------------------------- 
## aid_received3$year: 1967
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.07007  0.94631  2.38379  4.60471  5.99542 42.37892 
## -------------------------------------------------------- 
## aid_received3$year: 1968
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.00045  1.05250  3.15479  4.87291  6.16950 34.51436 
## -------------------------------------------------------- 
## aid_received3$year: 1969
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  0.005682  0.967556  2.552194  4.229600  6.333154 27.000294 
## -------------------------------------------------------- 
## aid_received3$year: 1970
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.00504  0.85000  2.62268  4.15566  5.73909 31.80635 
## -------------------------------------------------------- 
## aid_received3$year: 1971
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.01628  0.99658  2.51710  4.38114  6.06545 35.33910 
## -------------------------------------------------------- 
## aid_received3$year: 1972
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.00399  1.12404  2.73359  5.02737  5.80852 45.32969 
## -------------------------------------------------------- 
## aid_received3$year: 1973
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.0148  0.9003  2.4741  5.0559  6.9559 41.5708 
## -------------------------------------------------------- 
## aid_received3$year: 1974
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.00315  0.83989  2.58276  6.24655  9.73486 52.32022 
## -------------------------------------------------------- 
## aid_received3$year: 1975
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.01535  1.03119  2.89663  6.27436  7.92386 45.06606 
## -------------------------------------------------------- 
## aid_received3$year: 1976
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.02123  0.75321  2.54928  6.10898  8.50684 48.82969 
## -------------------------------------------------------- 
## aid_received3$year: 1977
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.00054  0.68560  3.37624  6.17797  8.81144 47.22268 
## -------------------------------------------------------- 
## aid_received3$year: 1978
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.03173  0.86971  4.04824  6.89517  9.50993 46.64241 
## -------------------------------------------------------- 
## aid_received3$year: 1979
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.1392  0.8769  3.6267  7.3190 10.5730 46.2533 
## -------------------------------------------------------- 
## aid_received3$year: 1980
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.03975  0.93112  4.65926  8.76088 10.39580 79.63180 
## -------------------------------------------------------- 
## aid_received3$year: 1981
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.03098  0.97643  4.64293  8.01527 10.67873 55.04959 
## -------------------------------------------------------- 
## aid_received3$year: 1982
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.03963  0.86093  4.60019  7.69544  9.73751 62.17212 
## -------------------------------------------------------- 
## aid_received3$year: 1983
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.00055  0.77468  4.56349  7.49577 10.11246 46.85706 
## -------------------------------------------------------- 
## aid_received3$year: 1984
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.04039  0.73691  3.93015  7.46616 10.33156 47.52077 
## -------------------------------------------------------- 
## aid_received3$year: 1985
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.00946  0.77424  4.37903  7.79665 11.00351 48.11748 
## -------------------------------------------------------- 
## aid_received3$year: 1986
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.03263  0.96993  5.27690  9.06783 11.48223 64.54760 
## -------------------------------------------------------- 
## aid_received3$year: 1987
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.07732  0.75768  4.46101  9.37230 11.51649 67.09700 
## -------------------------------------------------------- 
## aid_received3$year: 1988
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.1338  0.5745  4.9173  8.7453 11.9815 65.2736 
## -------------------------------------------------------- 
## aid_received3$year: 1989
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2334  0.5942  4.4653  9.0291 13.9451 57.2087 
## -------------------------------------------------------- 
## aid_received3$year: 1990
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.00868  1.02987  6.50899 10.25150 14.74109 61.65772 
## -------------------------------------------------------- 
## aid_received3$year: 1991
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2863  1.0621  5.4927  9.8185 13.7929 72.0603 
## -------------------------------------------------------- 
## aid_received3$year: 1992
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2973  0.7079  4.7030  9.7428 13.1469 81.2903 
## -------------------------------------------------------- 
## aid_received3$year: 1993
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2645  0.7014  4.1226  8.5139 13.6916 63.2279 
## -------------------------------------------------------- 
## aid_received3$year: 1994
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  -0.6676   0.7180   5.0412  11.9079  16.4678 242.2864 
## -------------------------------------------------------- 
## aid_received3$year: 1995
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  -0.1023   0.5191   4.1157  10.2854  14.8764 145.1223 
## -------------------------------------------------------- 
## aid_received3$year: 1996
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.4750  0.6786  4.4857  9.0431 13.3110 71.7857 
## -------------------------------------------------------- 
## aid_received3$year: 1997
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2537  0.7710  4.1296  7.6481 10.3815 48.9776 
## -------------------------------------------------------- 
## aid_received3$year: 1998
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.01482  0.96546  4.38994  7.88744 11.00570 75.78811 
## -------------------------------------------------------- 
## aid_received3$year: 1999
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2644  0.9713  4.3348  7.3823 10.5391 47.5355 
## -------------------------------------------------------- 
## aid_received3$year: 2000
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.02033  0.81122  3.85039  7.92049 11.31053 71.55631 
## -------------------------------------------------------- 
## aid_received3$year: 2001
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.04673  0.82919  3.70999  8.66956 12.33124 69.22282 
## -------------------------------------------------------- 
## aid_received3$year: 2002
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.1006  0.7972  5.6681  8.9226 12.0212 74.7611 
## -------------------------------------------------------- 
## aid_received3$year: 2003
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.6895  0.7806  3.5750  9.0470 12.9202 99.5132 
## -------------------------------------------------------- 
## aid_received3$year: 2004
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -2.7012  0.6649  3.9805  8.5303 12.2642 69.1472 
## -------------------------------------------------------- 
## aid_received3$year: 2005
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.09992  0.55176  3.92002  8.52561 11.22838 78.84479 
## -------------------------------------------------------- 
## aid_received3$year: 2006
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.1092  0.4615  3.6205  7.5080 11.1478 57.6217 
## -------------------------------------------------------- 
## aid_received3$year: 2007
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  -0.7303   0.4859   3.5980   7.6592  10.0495 119.9367 
## -------------------------------------------------------- 
## aid_received3$year: 2008
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  -0.2353   0.5021   3.3260   7.8747   9.5991 181.0143 
## -------------------------------------------------------- 
## aid_received3$year: 2009
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.03068  0.53664  3.85395  7.56540 10.30059 50.85367 
## -------------------------------------------------------- 
## aid_received3$year: 2010
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  -0.1797   0.6659   3.5271   8.4313  10.4137 127.4827

or What is the donor aid range for the middle 50% for Uganda?

# How has donor aid changed for countries
by(aid_received3$donor_aid, aid_received3$country, summary)
## aid_received3$country: Afghanistan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.6451  2.4129  3.1590 14.7526 33.4224 56.7412 
## -------------------------------------------------------- 
## aid_received3$country: Albania
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.2615  2.9348  6.3384  9.4506  8.2893 60.1823 
## -------------------------------------------------------- 
## aid_received3$country: Algeria
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1275  0.3133  0.5532  2.0824  1.5620 18.0484 
## -------------------------------------------------------- 
## aid_received3$country: Angola
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.3278  1.6546  3.9169  7.9567  9.5261 45.5397 
## -------------------------------------------------------- 
## aid_received3$country: Antigua and Barbuda
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1895  0.7726  1.3473  1.9883  2.2452  8.1584 
## -------------------------------------------------------- 
## aid_received3$country: Argentina
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.21391  0.04257  0.05695  0.06709  0.08660  0.30006 
## -------------------------------------------------------- 
## aid_received3$country: Armenia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1316  3.4941  9.1526  8.0328 10.9941 17.7966 
## -------------------------------------------------------- 
## aid_received3$country: Aruba
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.483   2.523   2.946   2.859   3.356   3.868 
## -------------------------------------------------------- 
## aid_received3$country: Azerbaijan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.3218  0.8859  2.7510  2.6723  4.1914  5.9698 
## -------------------------------------------------------- 
## aid_received3$country: Bahamas
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.02674  0.02630  0.09067  0.10169  0.13164  0.56536 
## -------------------------------------------------------- 
## aid_received3$country: Bahrain
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.08217  0.93081  1.96997  2.50315  3.63330  7.14529 
## -------------------------------------------------------- 
## aid_received3$country: Bangladesh
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.257   2.393   4.972   4.473   6.099   8.174 
## -------------------------------------------------------- 
## aid_received3$country: Barbados
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.08885  0.15089  0.59275  0.74275  1.28327  2.24454 
## -------------------------------------------------------- 
## aid_received3$country: Belarus
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1837  0.1878  0.1971  0.2046  0.2065  0.2552 
## -------------------------------------------------------- 
## aid_received3$country: Belize
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.7933  2.9136  6.6662  6.9514  9.1897 17.4121 
## -------------------------------------------------------- 
## aid_received3$country: Benin
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.00887  6.26093  8.14633  8.40234 10.29270 18.29659 
## -------------------------------------------------------- 
## aid_received3$country: Bermuda
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -0.667651  0.005140  0.008029  0.049340  0.027495  2.621474 
## -------------------------------------------------------- 
## aid_received3$country: Bhutan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.079  10.941  13.909  15.740  19.418  29.907 
## -------------------------------------------------------- 
## aid_received3$country: Bolivia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.220   3.306   5.894   6.399   9.378  12.229 
## -------------------------------------------------------- 
## aid_received3$country: Bosnia and Herzegovina
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.346   4.182   7.762  15.337  23.759  59.449 
## -------------------------------------------------------- 
## aid_received3$country: Botswana
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.3778  2.0352  8.9548  8.7657 12.9212 31.3823 
## -------------------------------------------------------- 
## aid_received3$country: Brazil
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.06727  0.03499  0.05251  0.24056  0.15976  1.74951 
## -------------------------------------------------------- 
## aid_received3$country: Brunei
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.09062 0.10400 0.12349 0.11884 0.12853 0.15274 
## -------------------------------------------------------- 
## aid_received3$country: Burkina Faso
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.05972  6.45573 11.39118 10.56621 13.24294 22.99788 
## -------------------------------------------------------- 
## aid_received3$country: Burundi
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.675   8.624  12.471  15.932  22.767  39.623 
## -------------------------------------------------------- 
## aid_received3$country: Cambodia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.9613  2.6227  7.2741  8.0823 10.9529 52.3202 
## -------------------------------------------------------- 
## aid_received3$country: Cameroon
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.673   3.047   4.441   4.518   5.378   9.711 
## -------------------------------------------------------- 
## aid_received3$country: Cape Verde
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   12.56   17.57   23.88   27.42   34.42   55.37 
## -------------------------------------------------------- 
## aid_received3$country: Central African Republic
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.02685  8.66739 11.66291 10.89616 13.29420 20.96450 
## -------------------------------------------------------- 
## aid_received3$country: Chad
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.00963  5.57596  8.66746  9.40153 12.39730 18.51848 
## -------------------------------------------------------- 
## aid_received3$country: Chile
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.13923  0.06636  0.16080  0.52797  0.41233  2.73098 
## -------------------------------------------------------- 
## aid_received3$country: China
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## 0.009557 0.082632 0.244249 0.277612 0.490470 0.730136 
## -------------------------------------------------------- 
## aid_received3$country: Colombia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2844  0.2099  0.3622  0.6453  0.8760  3.2750 
## -------------------------------------------------------- 
## aid_received3$country: Comoros
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   5.913  12.480  21.569  23.676  33.896  48.830 
## -------------------------------------------------------- 
## aid_received3$country: Congo, Dem. Rep.
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.672   2.154   3.217   9.025   6.253  99.513 
## -------------------------------------------------------- 
## aid_received3$country: Congo, Rep.
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.01544  4.33281  5.71272  7.42858  8.34251 35.35164 
## -------------------------------------------------------- 
## aid_received3$country: Costa Rica
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.1100  0.2427  1.4842  1.6531  2.2786  6.9042 
## -------------------------------------------------------- 
## aid_received3$country: Cote d'Ivoire
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.02336  1.86990  2.69796  3.99799  4.33715 21.13025 
## -------------------------------------------------------- 
## aid_received3$country: Croatia
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.0000989 0.2472066 0.2898192 0.3376140 0.4071480 0.7615334 
## -------------------------------------------------------- 
## aid_received3$country: Cuba
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.03259 0.07921 0.16687 0.16281 0.21240 0.32246 
## -------------------------------------------------------- 
## aid_received3$country: Cyprus
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.2371  0.6727  1.0566  2.3733  2.2356 12.6741 
## -------------------------------------------------------- 
## aid_received3$country: Djibouti
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   8.773  12.126  13.684  15.865  19.733  27.487 
## -------------------------------------------------------- 
## aid_received3$country: Dominica
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   3.560   6.416  10.051  11.439  15.260  29.646 
## -------------------------------------------------------- 
## aid_received3$country: Dominican Republic
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.01515  0.43061  0.91462  1.65361  2.09583  8.95253 
## -------------------------------------------------------- 
## aid_received3$country: Ecuador
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.2644  0.6468  1.1873  1.1871  1.6230  2.8169 
## -------------------------------------------------------- 
## aid_received3$country: Egypt
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1455  1.5509  4.2002  5.3582  6.0209 22.4042 
## -------------------------------------------------------- 
## aid_received3$country: El Salvador
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1158  1.3588  1.6683  3.2372  4.4167 10.9753 
## -------------------------------------------------------- 
## aid_received3$country: Equatorial Guinea
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.3053  1.0787  4.8344 15.3058 24.2072 53.9806 
## -------------------------------------------------------- 
## aid_received3$country: Eritrea
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.2096 11.2838 22.3129 20.9669 28.4497 41.4017 
## -------------------------------------------------------- 
## aid_received3$country: Ethiopia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.609   6.981   9.311  10.378  13.461  19.195 
## -------------------------------------------------------- 
## aid_received3$country: Fiji
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.8971  2.2165  2.7992  2.9238  3.3202  9.1596 
## -------------------------------------------------------- 
## aid_received3$country: French Polynesia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   6.232   8.581  10.346   9.943  11.447  13.465 
## -------------------------------------------------------- 
## aid_received3$country: Gabon
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.1979  0.9664  1.9620  2.5648  3.1774  7.7354 
## -------------------------------------------------------- 
## aid_received3$country: Gambia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.505   8.120  11.895  15.546  19.962  64.548 
## -------------------------------------------------------- 
## aid_received3$country: Georgia
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  0.003314  4.507567  5.882801  5.972226  8.165119 10.231154 
## -------------------------------------------------------- 
## aid_received3$country: Ghana
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.2315  2.7656  4.5999  6.1082  9.7003 16.3383 
## -------------------------------------------------------- 
## aid_received3$country: Grenada
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.959   3.169   4.171   5.356   6.712  17.259 
## -------------------------------------------------------- 
## aid_received3$country: Guatemala
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.7052  0.9617  1.1776  1.3572  1.5063  3.4828 
## -------------------------------------------------------- 
## aid_received3$country: Guinea
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   5.088   7.456  10.088   9.605  11.511  16.054 
## -------------------------------------------------------- 
## aid_received3$country: Guinea-Bissau
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.01119 18.22022 38.76210 36.75728 49.83088 78.70690 
## -------------------------------------------------------- 
## aid_received3$country: Guyana
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.100   5.271   7.500  12.331  14.723  61.173 
## -------------------------------------------------------- 
## aid_received3$country: Haiti
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.989  10.759  13.730  17.171  15.718  45.526 
## -------------------------------------------------------- 
## aid_received3$country: Honduras
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.386   2.906   4.963   5.722   7.735  16.035 
## -------------------------------------------------------- 
## aid_received3$country: Hong Kong, China
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.03874  0.01979  0.03933  0.06613  0.05873  0.43941 
## -------------------------------------------------------- 
## aid_received3$country: India
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1080  0.3842  0.7999  1.0032  1.3967  3.3503 
## -------------------------------------------------------- 
## aid_received3$country: Indonesia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.05381 0.77778 1.14235 1.59888 1.77130 5.93770 
## -------------------------------------------------------- 
## aid_received3$country: Iran
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.02123  0.02868  0.07002  0.10266  0.15708  0.44907 
## -------------------------------------------------------- 
## aid_received3$country: Iraq
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.00945  0.04725  0.17636  4.35616  0.51878 78.84479 
## -------------------------------------------------------- 
## aid_received3$country: Israel
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.387   1.951   3.094   3.386   4.119   8.537 
## -------------------------------------------------------- 
## aid_received3$country: Jamaica
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2644  0.7952  1.0785  2.4123  4.6830  9.1991 
## -------------------------------------------------------- 
## aid_received3$country: Jordan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   3.043   5.957   8.942  13.185  17.938  44.240 
## -------------------------------------------------------- 
## aid_received3$country: Kazakhstan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.0657  0.2613  0.5200  0.5546  0.7856  1.1104 
## -------------------------------------------------------- 
## aid_received3$country: Kenya
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.440   3.920   4.903   6.008   7.021  16.959 
## -------------------------------------------------------- 
## aid_received3$country: Kiribati
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.70   15.12   18.65   24.74   35.24   50.06 
## -------------------------------------------------------- 
## aid_received3$country: Kosovo
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.85   11.65   12.45   12.45   13.24   14.04 
## -------------------------------------------------------- 
## aid_received3$country: Kuwait
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -0.192570  0.002723  0.013609 -0.002009  0.019040  0.071600 
## -------------------------------------------------------- 
## aid_received3$country: Kyrgyz Republic
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.910   7.934  11.295  11.427  13.478  24.094 
## -------------------------------------------------------- 
## aid_received3$country: Lao
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.549   9.636  13.893  12.779  17.004  22.155 
## -------------------------------------------------------- 
## aid_received3$country: Lebanon
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.063   1.234   1.746   2.317   3.057   8.255 
## -------------------------------------------------------- 
## aid_received3$country: Lesotho
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   3.017   7.888  11.125  11.069  14.258  18.589 
## -------------------------------------------------------- 
## aid_received3$country: Liberia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.474   5.779  12.034  25.365  23.849 181.014 
## -------------------------------------------------------- 
## aid_received3$country: Libya
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.02620 0.05437 0.06517 0.05826 0.06624 0.07933 
## -------------------------------------------------------- 
## aid_received3$country: Macao, China
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -0.057742  0.004607  0.007022  0.012153  0.021107  0.062618 
## -------------------------------------------------------- 
## aid_received3$country: Macedonia, FYR
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1331  2.1825  3.0545  3.8226  5.4499  7.6874 
## -------------------------------------------------------- 
## aid_received3$country: Madagascar
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.2204  4.2040  6.5844  8.2088 10.6699 29.4712 
## -------------------------------------------------------- 
## aid_received3$country: Malawi
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.588  10.526  15.555  17.163  23.902  41.291 
## -------------------------------------------------------- 
## aid_received3$country: Malaysia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.4750  0.1386  0.5552  0.4722  0.7202  1.2013 
## -------------------------------------------------------- 
## aid_received3$country: Maldives
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.995   3.325   6.906   8.011  12.530  16.885 
## -------------------------------------------------------- 
## aid_received3$country: Mali
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   6.238  11.947  14.147  15.016  18.142  29.404 
## -------------------------------------------------------- 
## aid_received3$country: Malta
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2334  0.4511  1.1819  2.3418  4.6935  7.4680 
## -------------------------------------------------------- 
## aid_received3$country: Marshall Islands
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   25.44   30.31   35.44   36.93   44.49   53.93 
## -------------------------------------------------------- 
## aid_received3$country: Mauritania
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   3.792  11.219  18.631  19.664  25.412  46.408 
## -------------------------------------------------------- 
## aid_received3$country: Mauritius
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2532  0.5632  1.3919  1.9199  2.8755  5.2908 
## -------------------------------------------------------- 
## aid_received3$country: Mexico
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.06631  0.02148  0.07053  0.08513  0.11021  0.49472 
## -------------------------------------------------------- 
## aid_received3$country: Micronesia, Fed. Sts.
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   29.28   36.51   41.25   41.46   45.94   56.08 
## -------------------------------------------------------- 
## aid_received3$country: Moldova
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.367   4.299   5.531   5.878   7.799   9.351 
## -------------------------------------------------------- 
## aid_received3$country: Mongolia
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  0.005826  1.746935  8.884630  9.614989 16.242701 21.473334 
## -------------------------------------------------------- 
## aid_received3$country: Montenegro
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1694  0.8050  1.8876  1.7424  2.4266  3.4870 
## -------------------------------------------------------- 
## aid_received3$country: Morocco
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.8938  1.6128  2.3762  2.8400  3.4428  7.1018 
## -------------------------------------------------------- 
## aid_received3$country: Mozambique
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   3.972  20.082  23.883  28.538  39.837  81.290 
## -------------------------------------------------------- 
## aid_received3$country: Namibia
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## 0.000545 2.154156 3.162415 3.320828 4.998087 6.969916 
## -------------------------------------------------------- 
## aid_received3$country: Nepal
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.375   3.103   5.862   6.274   8.207  14.097 
## -------------------------------------------------------- 
## aid_received3$country: New Caledonia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   5.824   9.873  12.100  12.211  14.087  22.080 
## -------------------------------------------------------- 
## aid_received3$country: Nicaragua
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.682   2.859   6.308  10.953  12.951  72.060 
## -------------------------------------------------------- 
## aid_received3$country: Niger
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  0.008872  6.313576 11.851246 10.972668 15.153996 24.337310 
## -------------------------------------------------------- 
## aid_received3$country: Nigeria
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.05481 0.31533 0.67209 0.92933 1.01811 8.16925 
## -------------------------------------------------------- 
## aid_received3$country: Oman
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.07373  0.33977  0.65618  2.02690  2.07608 14.07049 
## -------------------------------------------------------- 
## aid_received3$country: Pakistan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.9267  1.6969  2.8964  3.5903  4.4785 10.4413 
## -------------------------------------------------------- 
## aid_received3$country: Palau
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##   0.01209  18.07372  25.28322  43.80963  32.70687 242.28641 
## -------------------------------------------------------- 
## aid_received3$country: Panama
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.7303  0.4284  1.1571  1.2309  1.8382  4.6488 
## -------------------------------------------------------- 
## aid_received3$country: Papua New Guinea
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  0.003653  7.036293 10.642458 11.826772 15.860981 24.209466 
## -------------------------------------------------------- 
## aid_received3$country: Paraguay
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.3292  0.9544  1.5423  1.7203  2.3500  4.0531 
## -------------------------------------------------------- 
## aid_received3$country: Peru
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.7450  0.6052  0.7848  0.8653  1.1509  2.4838 
## -------------------------------------------------------- 
## aid_received3$country: Philippines
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.02763 0.70463 0.97869 1.19419 1.47678 3.21914 
## -------------------------------------------------------- 
## aid_received3$country: Qatar
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.00329 0.01932 0.03046 0.03085 0.04226 0.07463 
## -------------------------------------------------------- 
## aid_received3$country: Rwanda
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    5.25   10.14   12.51   16.24   18.48   94.95 
## -------------------------------------------------------- 
## aid_received3$country: Samoa
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.322  11.243  18.482  18.570  23.441  35.066 
## -------------------------------------------------------- 
## aid_received3$country: Sao Tome and Principe
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   15.55   25.13   29.16   31.49   36.79   51.25 
## -------------------------------------------------------- 
## aid_received3$country: Saudi Arabia
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -0.595492  0.007763  0.011723  0.008765  0.021829  0.567179 
## -------------------------------------------------------- 
## aid_received3$country: Senegal
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   3.830   7.482   9.200   9.528  11.896  17.014 
## -------------------------------------------------------- 
## aid_received3$country: Serbia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.4548  1.8429  4.1454  5.5904  6.4365 18.6503 
## -------------------------------------------------------- 
## aid_received3$country: Seychelles
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.156   3.881   7.875   9.658  13.919  35.339 
## -------------------------------------------------------- 
## aid_received3$country: Sierra Leone
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.558   3.508  10.171  14.471  24.296  42.928 
## -------------------------------------------------------- 
## aid_received3$country: Singapore
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -0.008676  0.085537  0.163103  0.310364  0.315328  1.478439 
## -------------------------------------------------------- 
## aid_received3$country: Slovenia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.05657 0.19151 0.23901 0.28480 0.36549 0.61170 
## -------------------------------------------------------- 
## aid_received3$country: Solomon Islands
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.448  15.779  22.107  26.515  38.234  61.381 
## -------------------------------------------------------- 
## aid_received3$country: Somalia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    5.31   11.42   19.58   30.50   46.78   79.63 
## -------------------------------------------------------- 
## aid_received3$country: South Africa
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.2117  0.2808  0.3166  0.3315  0.3905  0.4720 
## -------------------------------------------------------- 
## aid_received3$country: South Korea
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -0.040387  0.003535  0.271374  1.998163  3.565100  9.586831 
## -------------------------------------------------------- 
## aid_received3$country: Sri Lanka
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.6796  1.9792  2.8209  4.4554  7.4490 12.8650 
## -------------------------------------------------------- 
## aid_received3$country: St. Kitts and Nevis
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  0.008721  1.781506  4.683908  4.372842  6.149531 13.269231 
## -------------------------------------------------------- 
## aid_received3$country: St. Lucia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  -2.701   2.197   4.208   4.086   5.747   9.252 
## -------------------------------------------------------- 
## aid_received3$country: St. Vincent and the Grenadines
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.3978  2.8837  7.3186  7.2244 10.3008 18.6955 
## -------------------------------------------------------- 
## aid_received3$country: Sudan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.3734  1.9356  4.1014  4.2336  6.1980 11.5951 
## -------------------------------------------------------- 
## aid_received3$country: Suriname
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.3861  2.5009  9.1823  7.6623 11.2433 20.0705 
## -------------------------------------------------------- 
## aid_received3$country: Swaziland
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.8424  1.8544  3.8533  7.5064 10.9432 31.2760 
## -------------------------------------------------------- 
## aid_received3$country: Syria
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.05924  0.45316  1.56877  3.89556  6.10870 19.80992 
## -------------------------------------------------------- 
## aid_received3$country: Tajikistan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.6201  5.8819  9.5675  9.1255 12.0331 16.0472 
## -------------------------------------------------------- 
## aid_received3$country: Tanzania
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.33   12.14   13.91   16.33   20.93   30.22 
## -------------------------------------------------------- 
## aid_received3$country: Thailand
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.6895  0.4684  0.8206  0.7023  1.0576  1.5899 
## -------------------------------------------------------- 
## aid_received3$country: Timor-Leste
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   8.331  11.715  21.841  35.074  62.760  74.761 
## -------------------------------------------------------- 
## aid_received3$country: Togo
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.09117  5.57283  7.93746  8.72231 12.67751 16.72519 
## -------------------------------------------------------- 
## aid_received3$country: Tonga
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.135  12.083  15.360  16.668  21.939  28.687 
## -------------------------------------------------------- 
## aid_received3$country: Trinidad and Tobago
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.10060  0.04212  0.16668  0.37153  0.42937  2.38704 
## -------------------------------------------------------- 
## aid_received3$country: Tunisia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.4332  1.1914  2.7796  3.6925  5.2156 10.8473 
## -------------------------------------------------------- 
## aid_received3$country: Turkey
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## 0.003072 0.129686 0.237252 0.429176 0.715067 1.410069 
## -------------------------------------------------------- 
## aid_received3$country: Turkmenistan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1001  0.4075  0.8938  0.8025  1.0182  2.1943 
## -------------------------------------------------------- 
## aid_received3$country: Tuvalu
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   21.86   24.35   28.74   29.98   35.69   40.30 
## -------------------------------------------------------- 
## aid_received3$country: Uganda
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.5715  2.6203  6.2293  8.4151 13.1502 26.1228 
## -------------------------------------------------------- 
## aid_received3$country: Ukraine
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.2989  0.3736  0.4610  0.4385  0.4791  0.5804 
## -------------------------------------------------------- 
## aid_received3$country: Uruguay
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.03699  0.10481  0.21105  0.37258  0.45958  3.30758 
## -------------------------------------------------------- 
## aid_received3$country: Uzbekistan
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.01167 0.59921 0.88125 0.93594 1.28023 2.05235 
## -------------------------------------------------------- 
## aid_received3$country: Vanuatu
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.75   13.67   18.74   21.48   27.64   45.88 
## -------------------------------------------------------- 
## aid_received3$country: Venezuela
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.61392  0.01937  0.04192  0.06964  0.07330  0.74569 
## -------------------------------------------------------- 
## aid_received3$country: Vietnam
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.873   3.010   3.823   3.850   4.432   5.931 
## -------------------------------------------------------- 
## aid_received3$country: West Bank and Gaza
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   11.79   14.21   14.67   19.65   27.39   30.69 
## -------------------------------------------------------- 
## aid_received3$country: Yemen
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.195   2.195   4.019   3.830   5.168   8.016 
## -------------------------------------------------------- 
## aid_received3$country: Zambia
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1469  2.4963  9.0272 12.2563 18.1747 62.7696 
## -------------------------------------------------------- 
## aid_received3$country: Zimbabwe
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##  0.000943  0.155966  3.231755  3.529253  4.485711 14.611034
# Interquartile range
by(aid_received3$donor_aid, aid_received3$year, IQR)
## aid_received3$year: 1960
## [1] 3.573398
## -------------------------------------------------------- 
## aid_received3$year: 1961
## [1] 4.429308
## -------------------------------------------------------- 
## aid_received3$year: 1962
## [1] 3.900023
## -------------------------------------------------------- 
## aid_received3$year: 1963
## [1] 3.364176
## -------------------------------------------------------- 
## aid_received3$year: 1964
## [1] 4.814258
## -------------------------------------------------------- 
## aid_received3$year: 1965
## [1] 5.146291
## -------------------------------------------------------- 
## aid_received3$year: 1966
## [1] 4.48739
## -------------------------------------------------------- 
## aid_received3$year: 1967
## [1] 5.049109
## -------------------------------------------------------- 
## aid_received3$year: 1968
## [1] 5.117003
## -------------------------------------------------------- 
## aid_received3$year: 1969
## [1] 5.365598
## -------------------------------------------------------- 
## aid_received3$year: 1970
## [1] 4.889087
## -------------------------------------------------------- 
## aid_received3$year: 1971
## [1] 5.068875
## -------------------------------------------------------- 
## aid_received3$year: 1972
## [1] 4.684476
## -------------------------------------------------------- 
## aid_received3$year: 1973
## [1] 6.055551
## -------------------------------------------------------- 
## aid_received3$year: 1974
## [1] 8.894967
## -------------------------------------------------------- 
## aid_received3$year: 1975
## [1] 6.892667
## -------------------------------------------------------- 
## aid_received3$year: 1976
## [1] 7.753639
## -------------------------------------------------------- 
## aid_received3$year: 1977
## [1] 8.125838
## -------------------------------------------------------- 
## aid_received3$year: 1978
## [1] 8.640223
## -------------------------------------------------------- 
## aid_received3$year: 1979
## [1] 9.69608
## -------------------------------------------------------- 
## aid_received3$year: 1980
## [1] 9.464682
## -------------------------------------------------------- 
## aid_received3$year: 1981
## [1] 9.702303
## -------------------------------------------------------- 
## aid_received3$year: 1982
## [1] 8.876575
## -------------------------------------------------------- 
## aid_received3$year: 1983
## [1] 9.337785
## -------------------------------------------------------- 
## aid_received3$year: 1984
## [1] 9.594654
## -------------------------------------------------------- 
## aid_received3$year: 1985
## [1] 10.22928
## -------------------------------------------------------- 
## aid_received3$year: 1986
## [1] 10.5123
## -------------------------------------------------------- 
## aid_received3$year: 1987
## [1] 10.75881
## -------------------------------------------------------- 
## aid_received3$year: 1988
## [1] 11.40706
## -------------------------------------------------------- 
## aid_received3$year: 1989
## [1] 13.3509
## -------------------------------------------------------- 
## aid_received3$year: 1990
## [1] 13.71122
## -------------------------------------------------------- 
## aid_received3$year: 1991
## [1] 12.73074
## -------------------------------------------------------- 
## aid_received3$year: 1992
## [1] 12.43898
## -------------------------------------------------------- 
## aid_received3$year: 1993
## [1] 12.99017
## -------------------------------------------------------- 
## aid_received3$year: 1994
## [1] 15.74981
## -------------------------------------------------------- 
## aid_received3$year: 1995
## [1] 14.35725
## -------------------------------------------------------- 
## aid_received3$year: 1996
## [1] 12.63244
## -------------------------------------------------------- 
## aid_received3$year: 1997
## [1] 9.610497
## -------------------------------------------------------- 
## aid_received3$year: 1998
## [1] 10.04024
## -------------------------------------------------------- 
## aid_received3$year: 1999
## [1] 9.567869
## -------------------------------------------------------- 
## aid_received3$year: 2000
## [1] 10.49931
## -------------------------------------------------------- 
## aid_received3$year: 2001
## [1] 11.50205
## -------------------------------------------------------- 
## aid_received3$year: 2002
## [1] 11.22396
## -------------------------------------------------------- 
## aid_received3$year: 2003
## [1] 12.1396
## -------------------------------------------------------- 
## aid_received3$year: 2004
## [1] 11.59922
## -------------------------------------------------------- 
## aid_received3$year: 2005
## [1] 10.67662
## -------------------------------------------------------- 
## aid_received3$year: 2006
## [1] 10.68627
## -------------------------------------------------------- 
## aid_received3$year: 2007
## [1] 9.563638
## -------------------------------------------------------- 
## aid_received3$year: 2008
## [1] 9.096919
## -------------------------------------------------------- 
## aid_received3$year: 2009
## [1] 9.763949
## -------------------------------------------------------- 
## aid_received3$year: 2010
## [1] 9.747878
# Interquartile range
by(aid_received3$donor_aid, aid_received3$country, IQR)
## aid_received3$country: Afghanistan
## [1] 31.00958
## -------------------------------------------------------- 
## aid_received3$country: Albania
## [1] 5.354514
## -------------------------------------------------------- 
## aid_received3$country: Algeria
## [1] 1.248733
## -------------------------------------------------------- 
## aid_received3$country: Angola
## [1] 7.871475
## -------------------------------------------------------- 
## aid_received3$country: Antigua and Barbuda
## [1] 1.472596
## -------------------------------------------------------- 
## aid_received3$country: Argentina
## [1] 0.04403653
## -------------------------------------------------------- 
## aid_received3$country: Armenia
## [1] 7.499971
## -------------------------------------------------------- 
## aid_received3$country: Aruba
## [1] 0.8327852
## -------------------------------------------------------- 
## aid_received3$country: Azerbaijan
## [1] 3.305505
## -------------------------------------------------------- 
## aid_received3$country: Bahamas
## [1] 0.1053386
## -------------------------------------------------------- 
## aid_received3$country: Bahrain
## [1] 2.702497
## -------------------------------------------------------- 
## aid_received3$country: Bangladesh
## [1] 3.70608
## -------------------------------------------------------- 
## aid_received3$country: Barbados
## [1] 1.132379
## -------------------------------------------------------- 
## aid_received3$country: Belarus
## [1] 0.01864809
## -------------------------------------------------------- 
## aid_received3$country: Belize
## [1] 6.276085
## -------------------------------------------------------- 
## aid_received3$country: Benin
## [1] 4.031771
## -------------------------------------------------------- 
## aid_received3$country: Bermuda
## [1] 0.022355
## -------------------------------------------------------- 
## aid_received3$country: Bhutan
## [1] 8.476069
## -------------------------------------------------------- 
## aid_received3$country: Bolivia
## [1] 6.072256
## -------------------------------------------------------- 
## aid_received3$country: Bosnia and Herzegovina
## [1] 19.57705
## -------------------------------------------------------- 
## aid_received3$country: Botswana
## [1] 10.88596
## -------------------------------------------------------- 
## aid_received3$country: Brazil
## [1] 0.1247647
## -------------------------------------------------------- 
## aid_received3$country: Brunei
## [1] 0.02452314
## -------------------------------------------------------- 
## aid_received3$country: Burkina Faso
## [1] 6.787204
## -------------------------------------------------------- 
## aid_received3$country: Burundi
## [1] 14.14331
## -------------------------------------------------------- 
## aid_received3$country: Cambodia
## [1] 8.330227
## -------------------------------------------------------- 
## aid_received3$country: Cameroon
## [1] 2.331879
## -------------------------------------------------------- 
## aid_received3$country: Cape Verde
## [1] 16.85021
## -------------------------------------------------------- 
## aid_received3$country: Central African Republic
## [1] 4.626815
## -------------------------------------------------------- 
## aid_received3$country: Chad
## [1] 6.821345
## -------------------------------------------------------- 
## aid_received3$country: Chile
## [1] 0.3459715
## -------------------------------------------------------- 
## aid_received3$country: China
## [1] 0.4078375
## -------------------------------------------------------- 
## aid_received3$country: Colombia
## [1] 0.6661153
## -------------------------------------------------------- 
## aid_received3$country: Comoros
## [1] 21.41557
## -------------------------------------------------------- 
## aid_received3$country: Congo, Dem. Rep.
## [1] 4.099208
## -------------------------------------------------------- 
## aid_received3$country: Congo, Rep.
## [1] 4.009701
## -------------------------------------------------------- 
## aid_received3$country: Costa Rica
## [1] 2.035898
## -------------------------------------------------------- 
## aid_received3$country: Cote d'Ivoire
## [1] 2.467253
## -------------------------------------------------------- 
## aid_received3$country: Croatia
## [1] 0.1599414
## -------------------------------------------------------- 
## aid_received3$country: Cuba
## [1] 0.1331895
## -------------------------------------------------------- 
## aid_received3$country: Cyprus
## [1] 1.562898
## -------------------------------------------------------- 
## aid_received3$country: Djibouti
## [1] 7.607588
## -------------------------------------------------------- 
## aid_received3$country: Dominica
## [1] 8.844007
## -------------------------------------------------------- 
## aid_received3$country: Dominican Republic
## [1] 1.665226
## -------------------------------------------------------- 
## aid_received3$country: Ecuador
## [1] 0.9762413
## -------------------------------------------------------- 
## aid_received3$country: Egypt
## [1] 4.470033
## -------------------------------------------------------- 
## aid_received3$country: El Salvador
## [1] 3.057862
## -------------------------------------------------------- 
## aid_received3$country: Equatorial Guinea
## [1] 23.12856
## -------------------------------------------------------- 
## aid_received3$country: Eritrea
## [1] 17.16592
## -------------------------------------------------------- 
## aid_received3$country: Ethiopia
## [1] 6.479464
## -------------------------------------------------------- 
## aid_received3$country: Fiji
## [1] 1.10365
## -------------------------------------------------------- 
## aid_received3$country: French Polynesia
## [1] 2.866343
## -------------------------------------------------------- 
## aid_received3$country: Gabon
## [1] 2.210985
## -------------------------------------------------------- 
## aid_received3$country: Gambia
## [1] 11.84186
## -------------------------------------------------------- 
## aid_received3$country: Georgia
## [1] 3.657552
## -------------------------------------------------------- 
## aid_received3$country: Ghana
## [1] 6.934699
## -------------------------------------------------------- 
## aid_received3$country: Grenada
## [1] 3.542874
## -------------------------------------------------------- 
## aid_received3$country: Guatemala
## [1] 0.544648
## -------------------------------------------------------- 
## aid_received3$country: Guinea
## [1] 4.05519
## -------------------------------------------------------- 
## aid_received3$country: Guinea-Bissau
## [1] 31.61066
## -------------------------------------------------------- 
## aid_received3$country: Guyana
## [1] 9.452215
## -------------------------------------------------------- 
## aid_received3$country: Haiti
## [1] 4.95824
## -------------------------------------------------------- 
## aid_received3$country: Honduras
## [1] 4.829152
## -------------------------------------------------------- 
## aid_received3$country: Hong Kong, China
## [1] 0.03894627
## -------------------------------------------------------- 
## aid_received3$country: India
## [1] 1.012521
## -------------------------------------------------------- 
## aid_received3$country: Indonesia
## [1] 0.9935149
## -------------------------------------------------------- 
## aid_received3$country: Iran
## [1] 0.1284038
## -------------------------------------------------------- 
## aid_received3$country: Iraq
## [1] 0.4715265
## -------------------------------------------------------- 
## aid_received3$country: Israel
## [1] 2.167245
## -------------------------------------------------------- 
## aid_received3$country: Jamaica
## [1] 3.887768
## -------------------------------------------------------- 
## aid_received3$country: Jordan
## [1] 11.98142
## -------------------------------------------------------- 
## aid_received3$country: Kazakhstan
## [1] 0.524281
## -------------------------------------------------------- 
## aid_received3$country: Kenya
## [1] 3.101492
## -------------------------------------------------------- 
## aid_received3$country: Kiribati
## [1] 20.12146
## -------------------------------------------------------- 
## aid_received3$country: Kosovo
## [1] 1.596393
## -------------------------------------------------------- 
## aid_received3$country: Kuwait
## [1] 0.01631685
## -------------------------------------------------------- 
## aid_received3$country: Kyrgyz Republic
## [1] 5.544564
## -------------------------------------------------------- 
## aid_received3$country: Lao
## [1] 7.368509
## -------------------------------------------------------- 
## aid_received3$country: Lebanon
## [1] 1.822363
## -------------------------------------------------------- 
## aid_received3$country: Lesotho
## [1] 6.369714
## -------------------------------------------------------- 
## aid_received3$country: Liberia
## [1] 18.07021
## -------------------------------------------------------- 
## aid_received3$country: Libya
## [1] 0.0118714
## -------------------------------------------------------- 
## aid_received3$country: Macao, China
## [1] 0.01649935
## -------------------------------------------------------- 
## aid_received3$country: Macedonia, FYR
## [1] 3.267394
## -------------------------------------------------------- 
## aid_received3$country: Madagascar
## [1] 6.465891
## -------------------------------------------------------- 
## aid_received3$country: Malawi
## [1] 13.37573
## -------------------------------------------------------- 
## aid_received3$country: Malaysia
## [1] 0.5815958
## -------------------------------------------------------- 
## aid_received3$country: Maldives
## [1] 9.205425
## -------------------------------------------------------- 
## aid_received3$country: Mali
## [1] 6.194552
## -------------------------------------------------------- 
## aid_received3$country: Malta
## [1] 4.242395
## -------------------------------------------------------- 
## aid_received3$country: Marshall Islands
## [1] 14.17526
## -------------------------------------------------------- 
## aid_received3$country: Mauritania
## [1] 14.19233
## -------------------------------------------------------- 
## aid_received3$country: Mauritius
## [1] 2.312329
## -------------------------------------------------------- 
## aid_received3$country: Mexico
## [1] 0.08873382
## -------------------------------------------------------- 
## aid_received3$country: Micronesia, Fed. Sts.
## [1] 9.438709
## -------------------------------------------------------- 
## aid_received3$country: Moldova
## [1] 3.49947
## -------------------------------------------------------- 
## aid_received3$country: Mongolia
## [1] 14.49577
## -------------------------------------------------------- 
## aid_received3$country: Montenegro
## [1] 1.621532
## -------------------------------------------------------- 
## aid_received3$country: Morocco
## [1] 1.829978
## -------------------------------------------------------- 
## aid_received3$country: Mozambique
## [1] 19.75557
## -------------------------------------------------------- 
## aid_received3$country: Namibia
## [1] 2.843931
## -------------------------------------------------------- 
## aid_received3$country: Nepal
## [1] 5.103969
## -------------------------------------------------------- 
## aid_received3$country: New Caledonia
## [1] 4.213733
## -------------------------------------------------------- 
## aid_received3$country: Nicaragua
## [1] 10.09194
## -------------------------------------------------------- 
## aid_received3$country: Niger
## [1] 8.84042
## -------------------------------------------------------- 
## aid_received3$country: Nigeria
## [1] 0.7027794
## -------------------------------------------------------- 
## aid_received3$country: Oman
## [1] 1.736313
## -------------------------------------------------------- 
## aid_received3$country: Pakistan
## [1] 2.781582
## -------------------------------------------------------- 
## aid_received3$country: Palau
## [1] 14.63316
## -------------------------------------------------------- 
## aid_received3$country: Panama
## [1] 1.40983
## -------------------------------------------------------- 
## aid_received3$country: Papua New Guinea
## [1] 8.824687
## -------------------------------------------------------- 
## aid_received3$country: Paraguay
## [1] 1.395606
## -------------------------------------------------------- 
## aid_received3$country: Peru
## [1] 0.5457125
## -------------------------------------------------------- 
## aid_received3$country: Philippines
## [1] 0.7721576
## -------------------------------------------------------- 
## aid_received3$country: Qatar
## [1] 0.02294564
## -------------------------------------------------------- 
## aid_received3$country: Rwanda
## [1] 8.346117
## -------------------------------------------------------- 
## aid_received3$country: Samoa
## [1] 12.19869
## -------------------------------------------------------- 
## aid_received3$country: Sao Tome and Principe
## [1] 11.66383
## -------------------------------------------------------- 
## aid_received3$country: Saudi Arabia
## [1] 0.0140664
## -------------------------------------------------------- 
## aid_received3$country: Senegal
## [1] 4.414217
## -------------------------------------------------------- 
## aid_received3$country: Serbia
## [1] 4.593645
## -------------------------------------------------------- 
## aid_received3$country: Seychelles
## [1] 10.03843
## -------------------------------------------------------- 
## aid_received3$country: Sierra Leone
## [1] 20.78866
## -------------------------------------------------------- 
## aid_received3$country: Singapore
## [1] 0.2297902
## -------------------------------------------------------- 
## aid_received3$country: Slovenia
## [1] 0.1739846
## -------------------------------------------------------- 
## aid_received3$country: Solomon Islands
## [1] 22.45449
## -------------------------------------------------------- 
## aid_received3$country: Somalia
## [1] 35.35439
## -------------------------------------------------------- 
## aid_received3$country: South Africa
## [1] 0.1096372
## -------------------------------------------------------- 
## aid_received3$country: South Korea
## [1] 3.561565
## -------------------------------------------------------- 
## aid_received3$country: Sri Lanka
## [1] 5.469812
## -------------------------------------------------------- 
## aid_received3$country: St. Kitts and Nevis
## [1] 4.368025
## -------------------------------------------------------- 
## aid_received3$country: St. Lucia
## [1] 3.550211
## -------------------------------------------------------- 
## aid_received3$country: St. Vincent and the Grenadines
## [1] 7.417094
## -------------------------------------------------------- 
## aid_received3$country: Sudan
## [1] 4.26236
## -------------------------------------------------------- 
## aid_received3$country: Suriname
## [1] 8.742418
## -------------------------------------------------------- 
## aid_received3$country: Swaziland
## [1] 9.08885
## -------------------------------------------------------- 
## aid_received3$country: Syria
## [1] 5.655545
## -------------------------------------------------------- 
## aid_received3$country: Tajikistan
## [1] 6.151212
## -------------------------------------------------------- 
## aid_received3$country: Tanzania
## [1] 8.792007
## -------------------------------------------------------- 
## aid_received3$country: Thailand
## [1] 0.5891911
## -------------------------------------------------------- 
## aid_received3$country: Timor-Leste
## [1] 51.04485
## -------------------------------------------------------- 
## aid_received3$country: Togo
## [1] 7.10468
## -------------------------------------------------------- 
## aid_received3$country: Tonga
## [1] 9.856532
## -------------------------------------------------------- 
## aid_received3$country: Trinidad and Tobago
## [1] 0.3872438
## -------------------------------------------------------- 
## aid_received3$country: Tunisia
## [1] 4.024134
## -------------------------------------------------------- 
## aid_received3$country: Turkey
## [1] 0.5853814
## -------------------------------------------------------- 
## aid_received3$country: Turkmenistan
## [1] 0.6106951
## -------------------------------------------------------- 
## aid_received3$country: Tuvalu
## [1] 11.33288
## -------------------------------------------------------- 
## aid_received3$country: Uganda
## [1] 10.52986
## -------------------------------------------------------- 
## aid_received3$country: Ukraine
## [1] 0.1055394
## -------------------------------------------------------- 
## aid_received3$country: Uruguay
## [1] 0.3547744
## -------------------------------------------------------- 
## aid_received3$country: Uzbekistan
## [1] 0.6810167
## -------------------------------------------------------- 
## aid_received3$country: Vanuatu
## [1] 13.96981
## -------------------------------------------------------- 
## aid_received3$country: Venezuela
## [1] 0.05393295
## -------------------------------------------------------- 
## aid_received3$country: Vietnam
## [1] 1.422546
## -------------------------------------------------------- 
## aid_received3$country: West Bank and Gaza
## [1] 13.18164
## -------------------------------------------------------- 
## aid_received3$country: Yemen
## [1] 2.973337
## -------------------------------------------------------- 
## aid_received3$country: Zambia
## [1] 15.67841
## -------------------------------------------------------- 
## aid_received3$country: Zimbabwe
## [1] 4.329745

Interquartile range

upper_quartile_1960 <- subset(aid_received3, donor_aid >= 10.3 & year == 1960)
upper_quartile_1960
## # A tibble: 4 x 3
##   country   year  donor_aid
##   <chr>     <chr>     <dbl>
## 1 Algeria   1960       11.0
## 2 Somalia   1960       11.9
## 3 Suriname  1960       10.4
## 4 Swaziland 1960       28.5
upper_quartile_2010 <- subset(aid_received3, donor_aid >= 10.3 & year == 2010)
upper_quartile_2010
## # A tibble: 34 x 3
##    country                  year  donor_aid
##    <chr>                    <chr>     <dbl>
##  1 Afghanistan              2010       40.9
##  2 Benin                    2010       10.5
##  3 Burkina Faso             2010       12.0
##  4 Burundi                  2010       31.0
##  5 Cape Verde               2010       20.7
##  6 Central African Republic 2010       13.2
##  7 Comoros                  2010       12.4
##  8 Congo, Dem. Rep.         2010       29.0
##  9 Congo, Rep.              2010       14.5
## 10 Ethiopia                 2010       13.3
## # ... with 24 more rows
max(by(aid_received3$donor_aid, aid_received3$year, IQR))
## [1] 15.74981
#15.74981

min(by(aid_received3$donor_aid, aid_received3$year, IQR))
## [1] 3.364176
#3.364176
max(by(aid_received3$donor_aid, aid_received3$country, IQR))
## [1] 51.04485
#51.04485
#looked up =  Timor-Leste (how to do this progmatically)

min(by(aid_received3$donor_aid, aid_received3$country, IQR))
## [1] 0.0118714
# 0.0118714)
# manually - libya(how do i do this progmatically?)

Question

if I want a table only of donor aid for the year 1960 say - I want to compare it with that of 2010 table(aid_received3[aid_received3$year]) == 1960 ???

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.