Clase 2

Punto 1 gráficos de dispersión

pairs(cars)

pairs(iris)

pairs(iris3)

#Sacamos la variable nominal

pairs(iris[,1:4])

Punto 2 Colores

library(RColorBrewer)

paleta <-  brewer.pal(3, "Set1")
paleta
## [1] "#E41A1C" "#377EB8" "#4DAF4A"
iris$Species
##   [1] setosa     setosa     setosa     setosa     setosa     setosa    
##   [7] setosa     setosa     setosa     setosa     setosa     setosa    
##  [13] setosa     setosa     setosa     setosa     setosa     setosa    
##  [19] setosa     setosa     setosa     setosa     setosa     setosa    
##  [25] setosa     setosa     setosa     setosa     setosa     setosa    
##  [31] setosa     setosa     setosa     setosa     setosa     setosa    
##  [37] setosa     setosa     setosa     setosa     setosa     setosa    
##  [43] setosa     setosa     setosa     setosa     setosa     setosa    
##  [49] setosa     setosa     versicolor versicolor versicolor versicolor
##  [55] versicolor versicolor versicolor versicolor versicolor versicolor
##  [61] versicolor versicolor versicolor versicolor versicolor versicolor
##  [67] versicolor versicolor versicolor versicolor versicolor versicolor
##  [73] versicolor versicolor versicolor versicolor versicolor versicolor
##  [79] versicolor versicolor versicolor versicolor versicolor versicolor
##  [85] versicolor versicolor versicolor versicolor versicolor versicolor
##  [91] versicolor versicolor versicolor versicolor versicolor versicolor
##  [97] versicolor versicolor versicolor versicolor virginica  virginica 
## [103] virginica  virginica  virginica  virginica  virginica  virginica 
## [109] virginica  virginica  virginica  virginica  virginica  virginica 
## [115] virginica  virginica  virginica  virginica  virginica  virginica 
## [121] virginica  virginica  virginica  virginica  virginica  virginica 
## [127] virginica  virginica  virginica  virginica  virginica  virginica 
## [133] virginica  virginica  virginica  virginica  virginica  virginica 
## [139] virginica  virginica  virginica  virginica  virginica  virginica 
## [145] virginica  virginica  virginica  virginica  virginica  virginica 
## Levels: setosa versicolor virginica
tipo  <- as.numeric(iris$Species)
tipo
##   [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
##  [36] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
##  [71] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
## [106] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [141] 3 3 3 3 3 3 3 3 3 3
colores <- paleta[tipo]
colores
##   [1] "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C"
##   [8] "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C"
##  [15] "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C"
##  [22] "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C"
##  [29] "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C"
##  [36] "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C"
##  [43] "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C" "#E41A1C"
##  [50] "#E41A1C" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8"
##  [57] "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8"
##  [64] "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8"
##  [71] "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8"
##  [78] "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8"
##  [85] "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8"
##  [92] "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8" "#377EB8"
##  [99] "#377EB8" "#377EB8" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A"
## [106] "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A"
## [113] "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A"
## [120] "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A"
## [127] "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A"
## [134] "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A"
## [141] "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A" "#4DAF4A"
## [148] "#4DAF4A" "#4DAF4A" "#4DAF4A"
pairs(iris[,1:4],
     # Título principal
     main = "Relación entre las variables largo y ancho del sépalo y pétalo 
     para las variedades de flor setosa, versicolor y virginica.", 
     pch = 21, # Tipo de la forma   
     cex.main = .95, # Tamaño del título
     bg = colores) # Colores por especio.

legend("bottom", # leyenda en la perte inferior
       title = "Especies :", # titulo de la leyenda
       legend = as.character(unique(iris$Species)), # nombres de los grupos
       fill = paleta, # colores de la leyenda
       horiz = TRUE, # leyenda de forma horizontal
       cex = .7, # tamaño del título
       xpd = T,
       inset = -0.1) # ubicación de la leyenda

Punto 3 Correlación en tres dimensiones y con más datos

library(scatterplot3d) # paquete para realizar los gráficos en 3D
par(oma = c(3,2,1,2)) # se hace espacio extra para agregar la leyenda
scatterplot3d(x = iris$Petal.Width, # eje x
              y = iris$Sepal.Length, # eje y
              z = iris$Sepal.Width,  # eje z
              xlab = "Ancho Del Pétalo",
              ylab = "Largo Del Sépalo",
              zlab = "Ancho Del Sépalo",
              bg = colores,
              pch = 21,
              angle = 190, # ángulo desde el que se obervan los datos.
              main = "Dispersión de los individuos por largo del sépalo,
              ancho del pétalo y ancho del sépalo.",
              cex.main = 1) # tamaño del título


library(GGally)
## Warning: package 'GGally' was built under R version 3.3.3

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.3.3
library(reshape)

ggpairs(data = iris, columns = 1:4, 
title = "Relación entre las variables largo y ancho del sépalo y pétalo \n para las variedades de flor setosa, versicolor y virginica", 
mapping = aes(color = Species, alpha = .7)) + 
theme_bw()

Punto 4 GRáfico de Barras

library(MASS)
## Warning: package 'MASS' was built under R version 3.3.2
data("painters")
head(painters)
##               Composition Drawing Colour Expression School
## Da Udine               10       8     16          3      A
## Da Vinci               15      16      4         14      A
## Del Piombo              8      13     16          7      A
## Del Sarto              12      16      9          8      A
## Fr. Penni               0      15      8          0      A
## Guilio Romano          15      16      4         14      A
datos <- as.matrix(painters[1,1:4]) # calificaciones del primer artista.
datos
##          Composition Drawing Colour Expression
## Da Udine          10       8     16          3
barplot(datos,
        main = "Calificaciones para el artista : Da Udine",
        cex.main = 1, # tamaño del título
        ylab = "Calificación")

datos <- as.data.frame(painters[1:5, 1:4]) # se seleccionan los primeros 5 pintores de la tabla 
datos
##            Composition Drawing Colour Expression
## Da Udine            10       8     16          3
## Da Vinci            15      16      4         14
## Del Piombo           8      13     16          7
## Del Sarto           12      16      9          8
## Fr. Penni            0      15      8          0
promedio.composition<-mean(datos$Composition)
promedio.drawing<-mean(datos$Drawing)
promedio.color<-mean(datos$Colour)
promedio.expresion<-mean(datos$Expression)

datos.graficos<-cbind(promedio.composition, promedio.drawing, promedio.color, promedio.expresion)

barplot(datos.graficos)

datos.especies<- table(iris$Species)
datos.especies.prop<- round(prop.table(datos.especies),3) * 100

colores <- brewer.pal(3, "Greens")

pie(x = datos.especies, 
    labels = datos.especies.prop,
    col = colores,
    main = "Distribución de las especies en la tabla de datos iris")

Punto 5 Combinaciones de varios gráficos

layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))

barplot(table(iris$Species))
title("Combinacion de varios graficos")
pie(table(iris$Species))
plot(iris$Sepal.Length,iris$Sepal.Width)

Punto 6 Graficos con volumen de casos

setwd("C:/Users/Acer/Desktop/EP_R")
datos <- read.table('WDS2014v2_1.csv', header=TRUE, sep=',',dec='.')
datos
##                       Country.Name      P2014  TMI  TFR   EVT   EVH   EVM
## 1                      Afghanistan   31627506 68.1 4.84 60.37 59.19 61.62
## 2                          Albania    2894475 12.9 1.78 77.83 75.37 80.42
## 3                          Algeria   38934334 22.0 2.86 74.81 72.51 77.22
## 4                           Angola   24227524 98.8 6.08 52.27 50.80 53.81
## 5              Antigua and Barbuda      90900  6.1 2.08 75.94 73.54 78.45
## 6                        Argentina   42980026 11.5 2.32 76.16 72.44 80.06
## 7                          Armenia    3006154 13.2 1.53 74.68 70.94 78.59
## 8                        Australia   23470118  3.2 1.86 82.25 80.30 84.30
## 9                          Austria    8545908  3.0 1.44 81.34 78.80 84.00
## 10                      Azerbaijan    9535079 28.9 2.00 70.76 67.69 73.99
## 11                         Bahrain    1361930  5.6 2.06 76.68 75.77 77.64
## 12                      Bangladesh  159077513 32.1 2.18 71.63 70.40 72.91
## 13                        Barbados     283380 12.3 1.79 75.50 73.15 77.96
## 14                         Belarus    9470000  3.5 1.62 72.98 68.00 78.20
## 15                         Belgium   11231213  3.4 1.75 80.59 78.10 83.20
## 16                          Belize     351706 14.6 2.58 70.08 67.36 72.94
## 17                           Benin   10598482 65.7 4.77 59.51 58.11 60.98
## 18                          Bhutan     765008 28.3 2.03 69.47 69.22 69.73
## 19                         Bolivia   10561887 31.7 2.97 68.34 65.94 70.86
## 20          Bosnia and Herzegovina    3817554  5.4 1.26 76.43 73.96 79.03
## 21                        Botswana    2219937 35.6 2.84 64.43 62.14 66.83
## 22                          Brazil  206077898 14.4 1.79 74.40 70.74 78.25
## 23               Brunei Darussalam     417394  8.5 1.87 78.81 76.99 80.72
## 24                        Bulgaria    7223938  9.7 1.48 75.41 71.70 79.30
## 25                    Burkina Faso   17589198 62.2 5.52 58.59 57.31 59.93
## 26                         Burundi   10816860 55.8 5.95 56.69 54.75 58.73
## 27                      Cabo Verde     513906 21.3 2.30 73.15 71.37 75.02
## 28                        Cambodia   15328136 26.3 2.64 68.21 66.22 70.30
## 29                        Cameroon   22773014 58.6 4.70 55.49 54.36 56.68
## 30                          Canada   35543658  4.4 1.61 81.96 80.02 83.99
## 31        Central African Republic    4804316 93.5 4.29 50.66 48.85 52.56
## 32                            Chad   13587053 86.7 6.16 51.56 50.51 52.66
## 33                           Chile   17762647  7.2 1.76 81.50 78.64 84.49
## 34                           China 1364270000  9.8 1.56 75.78 74.29 77.35
## 35                        Colombia   47791393 14.1 1.90 73.99 70.50 77.66
## 36                         Comoros     769991 56.6 4.49 63.26 61.63 64.96
## 37                      Costa Rica    4757606  8.6 1.82 79.40 77.01 81.91
## 38                    Cote dIvoire   22157107 68.5 5.00 51.56 50.74 52.42
## 39                         Croatia    4238389  3.8 1.46 77.33 74.50 80.30
## 40                            Cuba   11379111  4.1 1.62 79.39 77.38 81.50
## 41                          Cyprus    1153658  2.6 1.45 80.13 77.97 82.40
## 42                  Czech Republic   10525347  2.9 1.46 78.28 75.30 81.40
## 43                         Denmark    5638530  3.0 1.67 80.55 78.50 82.70
## 44                        Djibouti     876174 55.8 3.20 62.02 60.44 63.67
## 45              Dominican Republic   10405943 26.2 2.48 73.50 70.44 76.71
## 46                         Ecuador   15902916 19.0 2.54 75.87 73.19 78.69
## 47                  Egypt Arab Rep   89579670 21.0 3.34 71.12 68.99 73.36
## 48                     El Salvador    6107706 14.9 1.93 72.75 68.30 77.44
## 49               Equatorial Guinea     820885 70.3 4.84 57.65 56.33 59.03
## 50                         Eritrea    5110444 35.0 4.28 63.66 61.56 65.87
## 51                         Estonia    1314545  2.5 1.52 77.24 72.80 81.90
## 52                        Ethiopia   96958732 42.9 4.40 64.04 62.16 66.01
## 53                            Fiji     886450 19.4 2.56 70.09 67.15 73.17
## 54                         Finland    5461512  2.0 1.75 81.13 78.30 84.10
## 55                          France   66217509  3.6 1.99 82.37 79.30 85.60
## 56                           Gabon    1687673 37.0 3.91 64.38 63.76 65.04
## 57                          Gambia    1928201 48.6 5.72 60.23 58.91 61.62
## 58                         Georgia    3727000 11.3 1.82 74.67 71.15 78.36
## 59                         Germany   80970732  3.2 1.39 80.84 78.60 83.20
## 60                           Ghana   26786598 44.2 4.17 61.31 60.36 62.31
## 61                          Greece   10869637  3.7 1.30 81.29 78.70 84.00
## 62                         Grenada     106349 11.1 2.15 73.37 71.00 75.85
## 63                       Guatemala   16015494 25.1 3.21 71.72 68.28 75.34
## 64                          Guinea   12275527 62.8 5.01 58.73 58.27 59.22
## 65                   Guinea-Bissau    1800513 62.4 4.84 55.16 53.42 56.99
## 66                          Guyana     763893 32.6 2.56 66.41 64.16 68.76
## 67                           Haiti   10572029 53.5 3.03 62.75 60.67 64.93
## 68                        Honduras    7961680 18.0 2.38 73.14 70.68 75.71
## 69                         Hungary    9863183  5.3 1.35 75.87 72.80 79.10
## 70                         Iceland     327386  1.6 1.93 82.06 80.50 83.70
## 71                           India 1295291543 39.3 2.43 68.01 66.61 69.49
## 72                       Indonesia  254454778 23.6 2.46 68.89 66.87 71.01
## 73                            Iran   78143644 13.9 1.71 75.39 74.30 76.53
## 74                            Iraq   34812326 27.2 4.57 69.40 67.23 71.68
## 75                         Ireland    4615693  3.1 1.96 81.15 79.30 83.10
## 76                          Israel    8215700  3.3 3.08 82.15 80.30 84.10
## 77                           Italy   60789140  3.0 1.39 82.69 80.30 85.20
## 78                         Jamaica    2720554 13.9 2.05 75.65 73.31 78.11
## 79                           Japan  127131800  2.1 1.42 83.59 80.50 86.83
## 80                          Jordan    6607000 15.8 3.42 74.05 72.42 75.77
## 81                      Kazakhstan   17289224 13.5 2.74 71.62 67.12 75.94
## 82                           Kenya   44863583 36.6 4.33 61.58 59.85 63.39
## 83                        Kiribati     110470 44.6 3.73 65.95 62.82 69.24
## 84                      Korea Rep.   25026772 20.7 1.98 70.07 66.66 73.66
## 85                         Korea S   50423955  3.0 1.21 82.16 78.99 85.48
## 86                          Kuwait    3753121  7.7 2.11 74.59 73.47 75.76
## 87                 Kyrgyz Republic    5835500 20.1 3.20 70.40 66.50 74.50
## 88                         Lao PDR    6689300 52.3 2.99 66.12 64.77 67.53
## 89                          Latvia    1993782  7.2 1.52 74.19 69.70 78.90
## 90                         Lebanon    4546774  7.3 1.71 79.37 77.58 81.26
## 91                         Lesotho    2109197 70.5 3.19 49.70 49.58 49.82
## 92                         Liberia    4396554 54.7 4.72 60.83 59.87 61.85
## 93                           Libya    6258984 11.9 2.47 71.72 68.94 74.63
## 94                       Lithuania    2932367  3.6 1.59 73.97 68.60 79.60
## 95                      Luxembourg     556319  1.6 1.55 82.21 80.50 84.00
## 96                       Macedonia    2075625  5.2 1.52 75.34 73.10 77.70
## 97                      Madagascar   23571713 37.0 4.41 65.09 63.61 66.64
## 98                          Malawi   16695253 45.1 5.13 62.72 61.75 63.75
## 99                        Malaysia   29901997  6.2 1.94 74.72 72.43 77.12
## 100                       Maldives     401000  7.8 2.12 76.77 75.81 77.79
## 101                           Mali   17086022 75.9 6.23 57.99 58.18 57.79
## 102                          Malta     427364  5.2 1.38 81.75 79.60 84.00
## 103                     Mauritania    3969625 66.1 4.60 63.02 61.56 64.55
## 104                      Mauritius    1260934 12.2 1.43 74.19 70.97 77.58
## 105                         Mexico  125385833 11.9 2.24 76.72 74.36 79.21
## 106                 Micronesia Sts     104044 29.4 3.24 69.10 68.14 70.11
## 107                        Moldova    3556397 13.9 1.26 71.46 67.43 75.68
## 108                       Mongolia    2909871 19.9 2.66 69.46 65.28 73.86
## 109                     Montenegro     621810  4.6 1.69 76.18 74.07 78.40
## 110                        Morocco   33921203 24.6 2.52 74.02 73.02 75.06
## 111                     Mozambique   27216276 58.5 5.36 55.03 53.58 56.54
## 112                        Myanmar   53437159 40.7 2.20 65.86 63.85 67.96
## 113                        Namibia    2402858 33.4 3.52 64.68 62.15 67.34
## 114                          Nepal   28174724 30.5 2.22 69.60 68.21 71.07
## 115                    Netherlands   16865008  3.3 1.68 81.30 79.50 83.20
## 116                    New Zealand    4509700  4.8 1.92 81.40 79.60 83.30
## 117                      Nicaragua    6013913 19.4 2.26 74.81 71.86 77.91
## 118                          Niger   19113728 58.4 7.60 61.46 60.58 62.38
## 119                        Nigeria  177475986 71.5 5.65 52.75 52.43 53.10
## 120                         Norway    5136886  2.2 1.78 81.75 79.80 83.80
## 121                           Oman    4236057 10.0 2.77 77.09 75.07 79.20
## 122                       Pakistan  185044286 67.4 3.62 66.18 65.26 67.16
## 123                         Panama    3867535 15.1 2.44 77.60 74.62 80.72
## 124               Papua New Guinea    7463577 45.7 3.76 62.61 60.52 64.79
## 125                       Paraguay    6552518 18.1 2.54 72.92 70.83 75.12
## 126                           Peru   30973148 13.6 2.46 74.53 71.95 77.23
## 127                    Philippines   99138690 22.8 2.98 68.27 64.91 71.79
## 128                         Poland   38011735  4.5 1.29 77.25 73.40 81.30
## 129                       Portugal   10401062  3.0 1.21 80.72 77.60 84.00
## 130                          Qatar    2172065  7.0 2.03 78.60 77.35 79.91
## 131                        Romania   19904360 10.1 1.41 75.06 71.60 78.70
## 132             Russian Federation  143819569  8.5 1.70 70.37 65.00 76.00
## 133                         Rwanda   11341544 32.7 3.90 63.97 61.05 67.03
## 134                          Samoa     191845 15.4 4.09 73.51 70.41 76.77
## 135          Sao Tome and Principe     186342 35.5 4.58 66.38 64.43 68.44
## 136                   Saudi Arabia   30886545 12.9 2.77 74.34 73.03 75.71
## 137                        Senegal   14672557 42.3 5.09 66.37 64.52 68.32
## 138                         Serbia    7129366  6.0 1.43 75.53 72.90 78.30
## 139                     Seychelles      91400 11.9 2.30 73.23 68.40 78.30
## 140                   Sierra Leone    6315627 90.2 4.63 50.88 50.35 51.43
## 141                      Singapore    5469724  2.2 1.25 82.65 80.50 84.90
## 142                Slovak Republic    5418649  6.1 1.34 76.71 73.30 80.30
## 143                       Slovenia    2061980  2.2 1.55 80.52 77.30 83.90
## 144                Solomon Islands     572171 24.2 3.97 67.93 66.52 69.41
## 145                        Somalia   10517569 87.4 6.46 55.35 53.77 57.02
## 146                   South Africa   54001953 34.4 2.36 57.18 55.17 59.30
## 147                    South Sudan   11911184 62.0 5.02 55.68 54.73 56.68
## 148                          Spain   46476032  3.6 1.27 83.08 80.20 86.10
## 149                      Sri Lanka   20771000  8.6 2.08 74.79 71.51 78.25
## 150                      St. Lucia     183645 13.0 1.89 75.05 72.40 77.83
## 151 St. Vincent and the Grenadines     109360 17.0 1.97 72.94 70.87 75.11
## 152                          Sudan   39350274 48.8 4.35 63.46 61.98 65.01
## 153                       Suriname     538248 19.5 2.36 71.15 68.03 74.43
## 154                      Swaziland    1269112 45.8 3.27 48.93 49.62 48.21
## 155                         Sweden    9696110  2.4 1.89 81.96 80.20 83.80
## 156                    Switzerland    8188102  3.5 1.52 82.85 80.80 85.00
## 157           Syrian Arab Republic   22157800 11.7 2.95 70.07 63.97 76.48
## 158                     Tajikistan    8295840 39.7 3.49 69.60 66.20 73.17
## 159                       Tanzania   51822621 36.2 5.15 64.94 63.54 66.42
## 160                       Thailand   67725979 10.9 1.51 74.42 71.14 77.87
## 161                    Timor-Leste    1212107 46.1 5.10 68.26 66.55 70.06
## 162                           Togo    7115163 53.6 4.58 59.66 58.95 60.40
## 163                          Tonga     105586 14.7 3.72 72.79 69.92 75.81
## 164            Trinidad and Tobago    1354483 18.7 1.78 70.44 67.02 74.03
## 165                        Tunisia   10996600 12.6 2.20 74.14 71.90 76.50
## 166                         Turkey   75932348 12.3 2.07 75.16 71.98 78.50
## 167                   Turkmenistan    5307188 45.0 2.30 65.60 61.50 69.90
## 168                         Uganda   37782971 39.1 5.78 58.47 56.74 60.28
## 169                        Ukraine   45362900  8.1 1.50 71.19 66.25 76.37
## 170           United Arab Emirates    9086139  6.1 1.78 77.37 76.30 78.50
## 171                 United Kingdom   64559135  3.7 1.83 81.06 79.30 82.90
## 172                  United States  318857056  5.7 1.86 78.94 76.60 81.40
## 173                        Uruguay    3419516  9.1 2.02 76.99 73.51 80.63
## 174                     Uzbekistan   30757700 35.0 2.20 68.34 65.04 71.80
## 175                      Venezuela   30693827 13.2 2.37 74.24 70.20 78.47
## 176                        Vietnam   90728900 17.8 1.96 75.63 71.01 80.48
## 177             West Bank and Gaza    4294682 18.5 4.18 72.90 70.97 74.94
## 178                          Yemen   26183676 35.1 4.16 63.82 62.49 65.22
## 179                         Zambia   15721343 44.7 5.35 60.05 58.23 61.96
## 180                       Zimbabwe   15245855 47.6 3.92 57.50 56.17 58.89
##                            REG            ARE
## 1                   South Asia Asia & Oceania
## 2        Europe & Central Asia         Europe
## 3   Middle East & North Africa         Africa
## 4           Sub-Saharan Africa         Africa
## 5    Latin America & Caribbean        America
## 6    Latin America & Caribbean        America
## 7        Europe & Central Asia         Europe
## 8          East Asia & Pacific Asia & Oceania
## 9        Europe & Central Asia         Europe
## 10       Europe & Central Asia         Europe
## 11  Middle East & North Africa Asia & Oceania
## 12                  South Asia Asia & Oceania
## 13   Latin America & Caribbean        America
## 14       Europe & Central Asia         Europe
## 15       Europe & Central Asia         Europe
## 16   Latin America & Caribbean        America
## 17          Sub-Saharan Africa         Africa
## 18                  South Asia Asia & Oceania
## 19   Latin America & Caribbean        America
## 20       Europe & Central Asia         Europe
## 21          Sub-Saharan Africa         Africa
## 22   Latin America & Caribbean        America
## 23         East Asia & Pacific Asia & Oceania
## 24       Europe & Central Asia         Europe
## 25          Sub-Saharan Africa         Africa
## 26          Sub-Saharan Africa         Africa
## 27          Sub-Saharan Africa         Africa
## 28         East Asia & Pacific Asia & Oceania
## 29          Sub-Saharan Africa         Africa
## 30               North America        America
## 31          Sub-Saharan Africa         Africa
## 32          Sub-Saharan Africa         Africa
## 33   Latin America & Caribbean        America
## 34         East Asia & Pacific Asia & Oceania
## 35   Latin America & Caribbean        America
## 36          Sub-Saharan Africa         Africa
## 37   Latin America & Caribbean        America
## 38          Sub-Saharan Africa         Africa
## 39       Europe & Central Asia         Europe
## 40   Latin America & Caribbean        America
## 41       Europe & Central Asia         Europe
## 42       Europe & Central Asia         Europe
## 43       Europe & Central Asia         Europe
## 44  Middle East & North Africa         Africa
## 45   Latin America & Caribbean        America
## 46   Latin America & Caribbean        America
## 47  Middle East & North Africa         Africa
## 48   Latin America & Caribbean        America
## 49          Sub-Saharan Africa         Africa
## 50          Sub-Saharan Africa         Africa
## 51       Europe & Central Asia         Europe
## 52          Sub-Saharan Africa         Africa
## 53         East Asia & Pacific Asia & Oceania
## 54       Europe & Central Asia         Europe
## 55       Europe & Central Asia         Europe
## 56          Sub-Saharan Africa         Africa
## 57          Sub-Saharan Africa         Africa
## 58       Europe & Central Asia         Europe
## 59       Europe & Central Asia         Europe
## 60          Sub-Saharan Africa         Africa
## 61       Europe & Central Asia         Europe
## 62   Latin America & Caribbean        America
## 63   Latin America & Caribbean        America
## 64          Sub-Saharan Africa         Africa
## 65          Sub-Saharan Africa         Africa
## 66   Latin America & Caribbean        America
## 67   Latin America & Caribbean        America
## 68   Latin America & Caribbean        America
## 69       Europe & Central Asia         Europe
## 70       Europe & Central Asia         Europe
## 71                  South Asia Asia & Oceania
## 72         East Asia & Pacific Asia & Oceania
## 73  Middle East & North Africa Asia & Oceania
## 74  Middle East & North Africa Asia & Oceania
## 75       Europe & Central Asia         Europe
## 76  Middle East & North Africa Asia & Oceania
## 77       Europe & Central Asia         Europe
## 78   Latin America & Caribbean        America
## 79         East Asia & Pacific Asia & Oceania
## 80  Middle East & North Africa Asia & Oceania
## 81       Europe & Central Asia Asia & Oceania
## 82          Sub-Saharan Africa         Africa
## 83         East Asia & Pacific Asia & Oceania
## 84         East Asia & Pacific Asia & Oceania
## 85         East Asia & Pacific Asia & Oceania
## 86  Middle East & North Africa Asia & Oceania
## 87       Europe & Central Asia         Europe
## 88         East Asia & Pacific Asia & Oceania
## 89       Europe & Central Asia         Europe
## 90  Middle East & North Africa Asia & Oceania
## 91          Sub-Saharan Africa         Africa
## 92          Sub-Saharan Africa         Africa
## 93  Middle East & North Africa         Africa
## 94       Europe & Central Asia         Europe
## 95       Europe & Central Asia         Europe
## 96       Europe & Central Asia         Europe
## 97          Sub-Saharan Africa         Africa
## 98          Sub-Saharan Africa         Africa
## 99         East Asia & Pacific Asia & Oceania
## 100                 South Asia Asia & Oceania
## 101         Sub-Saharan Africa         Africa
## 102 Middle East & North Africa Asia & Oceania
## 103         Sub-Saharan Africa         Africa
## 104         Sub-Saharan Africa         Africa
## 105  Latin America & Caribbean        America
## 106        East Asia & Pacific Asia & Oceania
## 107      Europe & Central Asia         Europe
## 108        East Asia & Pacific Asia & Oceania
## 109      Europe & Central Asia         Europe
## 110 Middle East & North Africa         Africa
## 111         Sub-Saharan Africa         Africa
## 112        East Asia & Pacific Asia & Oceania
## 113         Sub-Saharan Africa         Africa
## 114                 South Asia Asia & Oceania
## 115      Europe & Central Asia         Europe
## 116        East Asia & Pacific Asia & Oceania
## 117  Latin America & Caribbean        America
## 118         Sub-Saharan Africa         Africa
## 119         Sub-Saharan Africa         Africa
## 120      Europe & Central Asia         Europe
## 121 Middle East & North Africa Asia & Oceania
## 122                 South Asia Asia & Oceania
## 123  Latin America & Caribbean        America
## 124        East Asia & Pacific Asia & Oceania
## 125  Latin America & Caribbean        America
## 126  Latin America & Caribbean        America
## 127        East Asia & Pacific Asia & Oceania
## 128      Europe & Central Asia         Europe
## 129      Europe & Central Asia         Europe
## 130 Middle East & North Africa Asia & Oceania
## 131      Europe & Central Asia         Europe
## 132        East Asia & Pacific Asia & Oceania
## 133         Sub-Saharan Africa         Africa
## 134        East Asia & Pacific Asia & Oceania
## 135         Sub-Saharan Africa         Africa
## 136 Middle East & North Africa Asia & Oceania
## 137         Sub-Saharan Africa         Africa
## 138      Europe & Central Asia         Europe
## 139         Sub-Saharan Africa         Africa
## 140         Sub-Saharan Africa         Africa
## 141        East Asia & Pacific Asia & Oceania
## 142      Europe & Central Asia         Europe
## 143      Europe & Central Asia         Europe
## 144        East Asia & Pacific Asia & Oceania
## 145         Sub-Saharan Africa         Africa
## 146         Sub-Saharan Africa         Africa
## 147         Sub-Saharan Africa         Africa
## 148      Europe & Central Asia         Europe
## 149                 South Asia Asia & Oceania
## 150  Latin America & Caribbean        America
## 151  Latin America & Caribbean        America
## 152         Sub-Saharan Africa         Africa
## 153  Latin America & Caribbean        America
## 154         Sub-Saharan Africa         Africa
## 155      Europe & Central Asia         Europe
## 156      Europe & Central Asia         Europe
## 157 Middle East & North Africa Asia & Oceania
## 158      Europe & Central Asia         Europe
## 159         Sub-Saharan Africa         Africa
## 160        East Asia & Pacific Asia & Oceania
## 161        East Asia & Pacific Asia & Oceania
## 162         Sub-Saharan Africa         Africa
## 163        East Asia & Pacific Asia & Oceania
## 164  Latin America & Caribbean        America
## 165 Middle East & North Africa         Africa
## 166      Europe & Central Asia         Europe
## 167      Europe & Central Asia Asia & Oceania
## 168         Sub-Saharan Africa         Africa
## 169      Europe & Central Asia         Europe
## 170 Middle East & North Africa Asia & Oceania
## 171      Europe & Central Asia         Europe
## 172              North America        America
## 173  Latin America & Caribbean        America
## 174      Europe & Central Asia Asia & Oceania
## 175  Latin America & Caribbean        America
## 176        East Asia & Pacific Asia & Oceania
## 177 Middle East & North Africa Asia & Oceania
## 178 Middle East & North Africa Asia & Oceania
## 179         Sub-Saharan Africa         Africa
## 180         Sub-Saharan Africa         Africa
P2014rec2 <- (datos$P2014/1000000)
P2014rec2
##   [1]   31.627506    2.894475   38.934334   24.227524    0.090900
##   [6]   42.980026    3.006154   23.470118    8.545908    9.535079
##  [11]    1.361930  159.077513    0.283380    9.470000   11.231213
##  [16]    0.351706   10.598482    0.765008   10.561887    3.817554
##  [21]    2.219937  206.077898    0.417394    7.223938   17.589198
##  [26]   10.816860    0.513906   15.328136   22.773014   35.543658
##  [31]    4.804316   13.587053   17.762647 1364.270000   47.791393
##  [36]    0.769991    4.757606   22.157107    4.238389   11.379111
##  [41]    1.153658   10.525347    5.638530    0.876174   10.405943
##  [46]   15.902916   89.579670    6.107706    0.820885    5.110444
##  [51]    1.314545   96.958732    0.886450    5.461512   66.217509
##  [56]    1.687673    1.928201    3.727000   80.970732   26.786598
##  [61]   10.869637    0.106349   16.015494   12.275527    1.800513
##  [66]    0.763893   10.572029    7.961680    9.863183    0.327386
##  [71] 1295.291543  254.454778   78.143644   34.812326    4.615693
##  [76]    8.215700   60.789140    2.720554  127.131800    6.607000
##  [81]   17.289224   44.863583    0.110470   25.026772   50.423955
##  [86]    3.753121    5.835500    6.689300    1.993782    4.546774
##  [91]    2.109197    4.396554    6.258984    2.932367    0.556319
##  [96]    2.075625   23.571713   16.695253   29.901997    0.401000
## [101]   17.086022    0.427364    3.969625    1.260934  125.385833
## [106]    0.104044    3.556397    2.909871    0.621810   33.921203
## [111]   27.216276   53.437159    2.402858   28.174724   16.865008
## [116]    4.509700    6.013913   19.113728  177.475986    5.136886
## [121]    4.236057  185.044286    3.867535    7.463577    6.552518
## [126]   30.973148   99.138690   38.011735   10.401062    2.172065
## [131]   19.904360  143.819569   11.341544    0.191845    0.186342
## [136]   30.886545   14.672557    7.129366    0.091400    6.315627
## [141]    5.469724    5.418649    2.061980    0.572171   10.517569
## [146]   54.001953   11.911184   46.476032   20.771000    0.183645
## [151]    0.109360   39.350274    0.538248    1.269112    9.696110
## [156]    8.188102   22.157800    8.295840   51.822621   67.725979
## [161]    1.212107    7.115163    0.105586    1.354483   10.996600
## [166]   75.932348    5.307188   37.782971   45.362900    9.086139
## [171]   64.559135  318.857056    3.419516   30.757700   30.693827
## [176]   90.728900    4.294682   26.183676   15.721343   15.245855
ggplot(data = datos, aes(x=ARE, y=TFR, size=P2014)) + geom_jitter(shape=21) + xlab("Area Geografica") + ylab("Tasa de fertilidad") + ggtitle("Relacion Area Geografica - Fertibilidad - Poblacion Paises en millones") + scale_y_continuous(breaks = 0:7) + theme_bw() + scale_size_continuous(name="Poblacion")

P2014rec2 <- (datos$P2014/1000000)
P2014rec2
##   [1]   31.627506    2.894475   38.934334   24.227524    0.090900
##   [6]   42.980026    3.006154   23.470118    8.545908    9.535079
##  [11]    1.361930  159.077513    0.283380    9.470000   11.231213
##  [16]    0.351706   10.598482    0.765008   10.561887    3.817554
##  [21]    2.219937  206.077898    0.417394    7.223938   17.589198
##  [26]   10.816860    0.513906   15.328136   22.773014   35.543658
##  [31]    4.804316   13.587053   17.762647 1364.270000   47.791393
##  [36]    0.769991    4.757606   22.157107    4.238389   11.379111
##  [41]    1.153658   10.525347    5.638530    0.876174   10.405943
##  [46]   15.902916   89.579670    6.107706    0.820885    5.110444
##  [51]    1.314545   96.958732    0.886450    5.461512   66.217509
##  [56]    1.687673    1.928201    3.727000   80.970732   26.786598
##  [61]   10.869637    0.106349   16.015494   12.275527    1.800513
##  [66]    0.763893   10.572029    7.961680    9.863183    0.327386
##  [71] 1295.291543  254.454778   78.143644   34.812326    4.615693
##  [76]    8.215700   60.789140    2.720554  127.131800    6.607000
##  [81]   17.289224   44.863583    0.110470   25.026772   50.423955
##  [86]    3.753121    5.835500    6.689300    1.993782    4.546774
##  [91]    2.109197    4.396554    6.258984    2.932367    0.556319
##  [96]    2.075625   23.571713   16.695253   29.901997    0.401000
## [101]   17.086022    0.427364    3.969625    1.260934  125.385833
## [106]    0.104044    3.556397    2.909871    0.621810   33.921203
## [111]   27.216276   53.437159    2.402858   28.174724   16.865008
## [116]    4.509700    6.013913   19.113728  177.475986    5.136886
## [121]    4.236057  185.044286    3.867535    7.463577    6.552518
## [126]   30.973148   99.138690   38.011735   10.401062    2.172065
## [131]   19.904360  143.819569   11.341544    0.191845    0.186342
## [136]   30.886545   14.672557    7.129366    0.091400    6.315627
## [141]    5.469724    5.418649    2.061980    0.572171   10.517569
## [146]   54.001953   11.911184   46.476032   20.771000    0.183645
## [151]    0.109360   39.350274    0.538248    1.269112    9.696110
## [156]    8.188102   22.157800    8.295840   51.822621   67.725979
## [161]    1.212107    7.115163    0.105586    1.354483   10.996600
## [166]   75.932348    5.307188   37.782971   45.362900    9.086139
## [171]   64.559135  318.857056    3.419516   30.757700   30.693827
## [176]   90.728900    4.294682   26.183676   15.721343   15.245855
ggplot(data = datos, aes(x=ARE, y=TFR, size=P2014rec2)) + geom_jitter(shape=21) + xlab("Area Geografica") + ylab("Tasa de fertilidad") + ggtitle("Relacion Area Geografica - Fertibilidad - Poblacion Paises en millones") + scale_y_continuous(breaks = 0:7) + theme_bw() + scale_size_continuous(name="Poblacion")

datos1<-subset(datos, ARE=="America")
datos1
##                       Country.Name     P2014  TMI  TFR   EVT   EVH   EVM
## 5              Antigua and Barbuda     90900  6.1 2.08 75.94 73.54 78.45
## 6                        Argentina  42980026 11.5 2.32 76.16 72.44 80.06
## 13                        Barbados    283380 12.3 1.79 75.50 73.15 77.96
## 16                          Belize    351706 14.6 2.58 70.08 67.36 72.94
## 19                         Bolivia  10561887 31.7 2.97 68.34 65.94 70.86
## 22                          Brazil 206077898 14.4 1.79 74.40 70.74 78.25
## 30                          Canada  35543658  4.4 1.61 81.96 80.02 83.99
## 33                           Chile  17762647  7.2 1.76 81.50 78.64 84.49
## 35                        Colombia  47791393 14.1 1.90 73.99 70.50 77.66
## 37                      Costa Rica   4757606  8.6 1.82 79.40 77.01 81.91
## 40                            Cuba  11379111  4.1 1.62 79.39 77.38 81.50
## 45              Dominican Republic  10405943 26.2 2.48 73.50 70.44 76.71
## 46                         Ecuador  15902916 19.0 2.54 75.87 73.19 78.69
## 48                     El Salvador   6107706 14.9 1.93 72.75 68.30 77.44
## 62                         Grenada    106349 11.1 2.15 73.37 71.00 75.85
## 63                       Guatemala  16015494 25.1 3.21 71.72 68.28 75.34
## 66                          Guyana    763893 32.6 2.56 66.41 64.16 68.76
## 67                           Haiti  10572029 53.5 3.03 62.75 60.67 64.93
## 68                        Honduras   7961680 18.0 2.38 73.14 70.68 75.71
## 78                         Jamaica   2720554 13.9 2.05 75.65 73.31 78.11
## 105                         Mexico 125385833 11.9 2.24 76.72 74.36 79.21
## 117                      Nicaragua   6013913 19.4 2.26 74.81 71.86 77.91
## 123                         Panama   3867535 15.1 2.44 77.60 74.62 80.72
## 125                       Paraguay   6552518 18.1 2.54 72.92 70.83 75.12
## 126                           Peru  30973148 13.6 2.46 74.53 71.95 77.23
## 150                      St. Lucia    183645 13.0 1.89 75.05 72.40 77.83
## 151 St. Vincent and the Grenadines    109360 17.0 1.97 72.94 70.87 75.11
## 153                       Suriname    538248 19.5 2.36 71.15 68.03 74.43
## 164            Trinidad and Tobago   1354483 18.7 1.78 70.44 67.02 74.03
## 172                  United States 318857056  5.7 1.86 78.94 76.60 81.40
## 173                        Uruguay   3419516  9.1 2.02 76.99 73.51 80.63
## 175                      Venezuela  30693827 13.2 2.37 74.24 70.20 78.47
##                           REG     ARE
## 5   Latin America & Caribbean America
## 6   Latin America & Caribbean America
## 13  Latin America & Caribbean America
## 16  Latin America & Caribbean America
## 19  Latin America & Caribbean America
## 22  Latin America & Caribbean America
## 30              North America America
## 33  Latin America & Caribbean America
## 35  Latin America & Caribbean America
## 37  Latin America & Caribbean America
## 40  Latin America & Caribbean America
## 45  Latin America & Caribbean America
## 46  Latin America & Caribbean America
## 48  Latin America & Caribbean America
## 62  Latin America & Caribbean America
## 63  Latin America & Caribbean America
## 66  Latin America & Caribbean America
## 67  Latin America & Caribbean America
## 68  Latin America & Caribbean America
## 78  Latin America & Caribbean America
## 105 Latin America & Caribbean America
## 117 Latin America & Caribbean America
## 123 Latin America & Caribbean America
## 125 Latin America & Caribbean America
## 126 Latin America & Caribbean America
## 150 Latin America & Caribbean America
## 151 Latin America & Caribbean America
## 153 Latin America & Caribbean America
## 164 Latin America & Caribbean America
## 172             North America America
## 173 Latin America & Caribbean America
## 175 Latin America & Caribbean America
P2014rec2 <- (datos1$P2014/1000000)
P2014rec2
##  [1]   0.090900  42.980026   0.283380   0.351706  10.561887 206.077898
##  [7]  35.543658  17.762647  47.791393   4.757606  11.379111  10.405943
## [13]  15.902916   6.107706   0.106349  16.015494   0.763893  10.572029
## [19]   7.961680   2.720554 125.385833   6.013913   3.867535   6.552518
## [25]  30.973148   0.183645   0.109360   0.538248   1.354483 318.857056
## [31]   3.419516  30.693827
ggplot(data = datos1, aes(x=Country.Name, y=TFR, size=P2014rec2)) + geom_jitter(shape=21) + xlab("Area Geografica") + ylab("Tasa de fertilidad") + ggtitle("Relacion Area Geografica - Fertibilidad - Poblacion Paises en millones") + scale_y_continuous(breaks = 0:32) + theme_bw() + scale_size_continuous(name="Poblacion")