Integrantes: - George Felipe Bedoya - Jennifer Ponce - Nelly Reyes - Almendra Rodriguez
library(nycflights13)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.3 ✓ purrr 0.3.4
## ✓ tibble 3.1.1 ✓ dplyr 1.0.7
## ✓ tidyr 1.1.3 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
flights
## # A tibble: 336,776 x 19
## year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time
## <int> <int> <int> <int> <int> <dbl> <int> <int>
## 1 2013 1 1 517 515 2 830 819
## 2 2013 1 1 533 529 4 850 830
## 3 2013 1 1 542 540 2 923 850
## 4 2013 1 1 544 545 -1 1004 1022
## 5 2013 1 1 554 600 -6 812 837
## 6 2013 1 1 554 558 -4 740 728
## 7 2013 1 1 555 600 -5 913 854
## 8 2013 1 1 557 600 -3 709 723
## 9 2013 1 1 557 600 -3 838 846
## 10 2013 1 1 558 600 -2 753 745
## # … with 336,766 more rows, and 11 more variables: arr_delay <dbl>,
## # carrier <chr>, flight <int>, tailnum <chr>, origin <chr>, dest <chr>,
## # air_time <dbl>, distance <dbl>, hour <dbl>, minute <dbl>, time_hour <dttm>
flights2 <- select (flights,mes=month, dia=day, anio=year, dep_delay, dep_time, sched_dep_time )
flights3 <-relocate (flights2, dep_delay,dia, mes, anio, dep_time,sched_dep_time)
flights3
## # A tibble: 336,776 x 6
## dep_delay dia mes anio dep_time sched_dep_time
## <dbl> <int> <int> <int> <int> <int>
## 1 2 1 1 2013 517 515
## 2 4 1 1 2013 533 529
## 3 2 1 1 2013 542 540
## 4 -1 1 1 2013 544 545
## 5 -6 1 1 2013 554 600
## 6 -4 1 1 2013 554 558
## 7 -5 1 1 2013 555 600
## 8 -3 1 1 2013 557 600
## 9 -3 1 1 2013 557 600
## 10 -2 1 1 2013 558 600
## # … with 336,766 more rows
Forma 2:
select(flights, dep_delay,dia=day, mes=month, anio=year,
dep_time,sched_dep_time)
## # A tibble: 336,776 x 6
## dep_delay dia mes anio dep_time sched_dep_time
## <dbl> <int> <int> <int> <int> <int>
## 1 2 1 1 2013 517 515
## 2 4 1 1 2013 533 529
## 3 2 1 1 2013 542 540
## 4 -1 1 1 2013 544 545
## 5 -6 1 1 2013 554 600
## 6 -4 1 1 2013 554 558
## 7 -5 1 1 2013 555 600
## 8 -3 1 1 2013 557 600
## 9 -3 1 1 2013 557 600
## 10 -2 1 1 2013 558 600
## # … with 336,766 more rows
Forma 3:
select(flights,
dep_delay,
dia = day,
mes = month,
anio = year,
contains("dep"))
## # A tibble: 336,776 x 6
## dep_delay dia mes anio dep_time sched_dep_time
## <dbl> <int> <int> <int> <int> <int>
## 1 2 1 1 2013 517 515
## 2 4 1 1 2013 533 529
## 3 2 1 1 2013 542 540
## 4 -1 1 1 2013 544 545
## 5 -6 1 1 2013 554 600
## 6 -4 1 1 2013 554 558
## 7 -5 1 1 2013 555 600
## 8 -3 1 1 2013 557 600
## 9 -3 1 1 2013 557 600
## 10 -2 1 1 2013 558 600
## # … with 336,766 more rows