Se carga la librería readr() que permit importar datos
library(readr)
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)
Muestra los primeros registros u bservaciones de un data frame
head(datos.covid, 15)
## SNo ObservationDate Province.State Country.Region Last.Update Confirmed
## 1 1 01/22/2020 Anhui Mainland China 1/22/2020 17:00 1
## 2 2 01/22/2020 Beijing Mainland China 1/22/2020 17:00 14
## 3 3 01/22/2020 Chongqing Mainland China 1/22/2020 17:00 6
## 4 4 01/22/2020 Fujian Mainland China 1/22/2020 17:00 1
## 5 5 01/22/2020 Gansu Mainland China 1/22/2020 17:00 0
## 6 6 01/22/2020 Guangdong Mainland China 1/22/2020 17:00 26
## 7 7 01/22/2020 Guangxi Mainland China 1/22/2020 17:00 2
## 8 8 01/22/2020 Guizhou Mainland China 1/22/2020 17:00 1
## 9 9 01/22/2020 Hainan Mainland China 1/22/2020 17:00 4
## 10 10 01/22/2020 Hebei Mainland China 1/22/2020 17:00 1
## 11 11 01/22/2020 Heilongjiang Mainland China 1/22/2020 17:00 0
## 12 12 01/22/2020 Henan Mainland China 1/22/2020 17:00 5
## 13 13 01/22/2020 Hong Kong Hong Kong 1/22/2020 17:00 0
## 14 14 01/22/2020 Hubei Mainland China 1/22/2020 17:00 444
## 15 15 01/22/2020 Hunan Mainland China 1/22/2020 17:00 4
## Deaths Recovered
## 1 0 0
## 2 0 0
## 3 0 0
## 4 0 0
## 5 0 0
## 6 0 0
## 7 0 0
## 8 0 0
## 9 0 0
## 10 0 0
## 11 0 0
## 12 0 0
## 13 0 0
## 14 17 28
## 15 0 0
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