1 Importar datos

1.1 Cargar librería

Se carga la librería readr() que permit importar datos

library(readr)

1.2 Cargar datos tipo csv

Se utiliza la función read.csv() para cargar os daos y almacenarlo en una variable llamada datos

Se puede importar datos del disco local de la computadora

datos <- read.csv(file = "../datos/personas.2.csv", header = TRUE, 
         sep = ",")
datos
##    id nombres edades generos feliz estaturas pesos    zonas
## 1   1    Juan     24       M  TRUE      1.65    80   CENTRO
## 2   2   Pedro     34       M FALSE      1.70    70      SUR
## 3   3    Luis     51       M  TRUE      1.54    75      SUR
## 4   4 Aracely     32       F  TRUE      1.72    60   CENTRO
## 5   5   Rubén     45       M FALSE      1.70    65  ORIENTE
## 6   6   Linda     30       F  TRUE      1.80    70 PONIENTE
## 7   7  Brenda     43       F FALSE      1.90    86   CENTRO
## 8   8    Lucy     54       F  TRUE      1.75    90      SUR
## 9   9 Liliana     54       F FALSE      1.72    50 PONIENTE
## 10 10 Aracely     23       F  TRUE      1.65    76   CENTRO
## 11 11    Luis     34       M FALSE      1.78    78      SUR
## 12 12 Gabriel     23       M  TRUE      1.90    89    NORTE
## 13 13  Jimena     45       F FALSE      1.65    65      SUR

También se puede importar datos de una dirección URL de internet, por ejemplo importar datos de afectaciones por covid hasta el mes de Febrero del 2020.

URL <- "https://raw.githubusercontent.com/rpizarrog/FundamentosMachineLearning/master/datos/covid_19_data.csv"
datos.covid <- read.csv(URL)

1.2.2 tail()

Muestra los últimos registros

tail(datos.covid, 15)
##       SNo ObservationDate                       Province.State Country.Region
## 2365 2365      02/25/2020                                           Sri Lanka
## 2366 2366      02/25/2020                                              Sweden
## 2367 2367      02/25/2020                                         Switzerland
## 2368 2368      02/25/2020                           Boston, MA             US
## 2369 2369      02/25/2020                  Humboldt County, CA             US
## 2370 2370      02/25/2020                      Los Angeles, CA             US
## 2371 2371      02/25/2020                          Madison, WI             US
## 2372 2372      02/25/2020                           Orange, CA             US
## 2373 2373      02/25/2020                Sacramento County, CA             US
## 2374 2374      02/25/2020                      San Antonio, TX             US
## 2375 2375      02/25/2020                          Seattle, WA             US
## 2376 2376      02/25/2020                            Tempe, AZ             US
## 2377 2377      02/25/2020 Lackland, TX (From Diamond Princess)             US
## 2378 2378      02/25/2020    Omaha, NE (From Diamond Princess)             US
## 2379 2379      02/25/2020   Travis, CA (From Diamond Princess)             US
##              Last.Update Confirmed Deaths Recovered
## 2365 2020-02-08T03:43:03         1      0         1
## 2366 2020-02-01T02:13:26         1      0         0
## 2367 2020-02-25T19:13:21         1      0         0
## 2368 2020-02-01T19:43:03         1      0         0
## 2369 2020-02-21T05:13:09         1      0         0
## 2370 2020-02-01T19:53:03         1      0         0
## 2371 2020-02-05T21:53:02         1      0         0
## 2372 2020-02-01T19:53:03         1      0         0
## 2373 2020-02-21T23:13:16         1      0         0
## 2374 2020-02-13T18:53:02         1      0         0
## 2375 2020-02-09T07:03:04         1      0         1
## 2376 2020-02-25T21:23:03         1      0         1
## 2377 2020-02-24T23:33:02         0      0         0
## 2378 2020-02-24T23:33:02         0      0         0
## 2379 2020-02-24T23:33:02         0      0         0