Rette che si intersecano non sono parallele

Programmare con dplyr

Dr. Chester Ismay

Educator, Data Scientist, and R/Python Consultant

Operazioni di insiemistica

  • Confronta e combina dati da due fonti

  • dplyr ha funzioni per operazioni di teoria degli insiemi sui tibble

Programmare con dplyr

Diagrammi di Venn per insiemi

Venn intersezione

Venn unione

Venn unione_all

Venn setdiff

Programmare con dplyr

diagramma di intersect

diagramma di intersect

Programmare con dplyr

Tibble dell’Uruguay

uruguay_imf
# A tibble: 9 x 4
  iso   country  year consumer_price_index
  <chr> <chr>   <int>                <dbl>
1 URY   Uruguay  2011                 105.
2 URY   Uruguay  2012                 114.
3 URY   Uruguay  2013                 123.
4 URY   Uruguay  2014                 134.
5 URY   Uruguay  2015                 146.
6 URY   Uruguay  2016                 160.
7 URY   Uruguay  2017                 170.
8 URY   Uruguay  2018                 183.
9 URY   Uruguay  2019                 197.
uruguay_wb
# A tibble: 4 x 4
  iso   country  year perc_rural_pop
  <chr> <chr>   <dbl>          <dbl>
1 URY   Uruguay  2013           5.16
2 URY   Uruguay  2014           5.06
3 URY   Uruguay  2015           4.96
4 URY   Uruguay  2016           4.86
Programmare con dplyr

Provare intersect()

intersect(uruguay_imf, uruguay_wb)
Error: not compatible: 
not compatible: 
- Cols in y but not x: `perc_rural_pop`.
- Cols in x but not y: `consumer_price_index`.
intersect(uruguay_imf$year, uruguay_wb$year)
[1] 2013 2014 2015 2016
Programmare con dplyr

Differenza tra intersect() e un join

  • intersect() cerca righe in comune
  • inner_join() cerca corrispondenze sui singoli key

Questa differenza è importante.

Programmare con dplyr

Ayo berlatih!

Programmare con dplyr

Preparing Video For Download...