library(dplyr)
##
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(readr)
basketball<- read.csv("playerstats.csv")
#Se intentara demostrar a partir de la base de datos cual es el mejor jugador extranjero de la NBA en base a sus eficiencia de tiro #Billboard
basketball %>%
select(League:PTS, 'nationality') %>%
head(20)
## League Season Stage Player Team GP MIN FGM FGA
## 1 NBA 1999 - 2000 Regular_Season Shaquille O'Neal LAL 79 3163 956 1665
## 2 NBA 1999 - 2000 Regular_Season Vince Carter TOR 82 3126 788 1696
## 3 NBA 1999 - 2000 Regular_Season Karl Malone UTA 82 2947 752 1476
## 4 NBA 1999 - 2000 Regular_Season Allen Iverson PHI 70 2853 729 1733
## 5 NBA 1999 - 2000 Regular_Season Gary Payton SEA 82 3425 747 1666
## 6 NBA 1999 - 2000 Regular_Season Jerry Stackhouse DET 82 3148 619 1447
## 7 NBA 1999 - 2000 Regular_Season Grant Hill DET 74 2776 696 1422
## 8 NBA 1999 - 2000 Regular_Season Kevin Garnett MIN 81 3243 759 1526
## 9 NBA 1999 - 2000 Regular_Season Michael Finley DAL 82 3464 748 1636
## 10 NBA 1999 - 2000 Regular_Season Chris Webber SAC 75 2880 748 1548
## 11 NBA 1999 - 2000 Regular_Season Ray Allen MIL 82 3070 642 1411
## 12 NBA 1999 - 2000 Regular_Season Alonzo Mourning MIA 79 2748 652 1184
## 13 NBA 1999 - 2000 Regular_Season Tim Duncan SAS 74 2875 628 1281
## 14 NBA 1999 - 2000 Regular_Season Glenn Robinson MIL 81 2909 690 1461
## 15 NBA 1999 - 2000 Regular_Season Antoine Walker BOS 82 3003 648 1506
## 16 NBA 1999 - 2000 Regular_Season Shareef Abdur-Rahim VAN 82 3223 594 1277
## 17 NBA 1999 - 2000 Regular_Season Stephon Marbury NJN 74 2881 569 1317
## 18 NBA 1999 - 2000 Regular_Season Elton Brand CHI 81 2999 630 1306
## 19 NBA 1999 - 2000 Regular_Season Allan Houston NYK 82 3169 614 1271
## 20 NBA 1999 - 2000 Regular_Season Antonio McDyess DEN 81 2698 614 1211
## X3PM X3PA FTM FTA TOV PF ORB DRB REB AST STL BLK PTS nationality
## 1 0 1 432 824 223 255 336 742 1078 299 36 239 2344 United States
## 2 95 236 436 551 178 263 150 326 476 322 110 92 2107 United States
## 3 2 8 589 739 231 229 169 610 779 304 79 71 2095 United States
## 4 89 261 442 620 230 162 71 196 267 328 144 5 1989 United States
## 5 177 520 311 423 224 178 100 429 529 732 153 18 1982 United States
## 6 83 288 618 758 311 188 118 197 315 365 103 36 1939 United States
## 7 34 98 480 604 240 190 97 393 490 385 103 43 1906 United States
## 8 30 81 309 404 268 205 223 733 956 401 120 126 1857 United States
## 9 99 247 260 317 196 171 122 396 518 438 109 32 1855 United States
## 10 27 95 311 414 218 264 189 598 787 345 120 128 1834 United States
## 11 172 407 353 398 183 187 83 276 359 308 110 19 1809 United States
## 12 0 4 414 582 217 308 215 538 753 123 40 294 1718 United States
## 13 1 11 459 603 242 210 262 656 918 234 66 165 1716 United States
## 14 86 237 227 283 223 212 107 378 485 193 78 41 1693 United States
## 15 73 285 311 445 259 263 199 453 652 305 117 32 1680 United States
## 16 29 96 446 551 249 244 218 607 825 271 89 87 1663 United States
## 17 66 233 436 536 270 195 61 179 240 622 112 15 1640 United States
## 18 0 2 367 536 228 259 348 462 810 155 66 132 1627 United States
## 19 106 243 280 334 186 219 38 233 271 224 65 14 1614 United States
## 20 0 2 323 516 230 316 234 451 685 159 69 139 1551 United States
#Se excluira a los jugadores nativos de Estados Unidos y se tomara en ceunta el historico de paises que mas aporta jugadores a la liga #Filter
basketball %>%
select(League:PTS, 'nationality') %>%
filter(PTS >= 1500, nationality == 'Serbia' | nationality == 'France' | nationality == 'Germany' | nationality == 'Canada' | nationality == 'Australia' | nationality == 'Brasil' | nationality == 'Croatia' | nationality == 'Spain' | nationality == 'Slovenia')
## League Season Stage Player Team GP MIN FGM FGA
## 1 NBA 2000 - 2001 Regular_Season Dirk Nowitzki DAL 82 3125.0 591 1247
## 2 NBA 2001 - 2002 Regular_Season Dirk Nowitzki DAL 76 2891.0 600 1258
## 3 NBA 2002 - 2003 Regular_Season Dirk Nowitzki DAL 80 3118.0 690 1489
## 4 NBA 2002 - 2003 Regular_Season Pau Gasol MEM 82 2947.0 569 1116
## 5 NBA 2003 - 2004 Regular_Season Dirk Nowitzki DAL 77 2915.0 605 1310
## 6 NBA 2004 - 2005 Regular_Season Dirk Nowitzki DAL 78 3021.0 663 1445
## 7 NBA 2005 - 2006 Regular_Season Dirk Nowitzki DAL 81 3089.2 751 1564
## 8 NBA 2005 - 2006 Regular_Season Pau Gasol MEM 80 3135.2 600 1194
## 9 NBA 2005 - 2006 Regular_Season Tony Parker SAS 80 2714.9 623 1136
## 10 NBA 2006 - 2007 Regular_Season Dirk Nowitzki DAL 78 2820.8 673 1341
## 11 NBA 2007 - 2008 Regular_Season Dirk Nowitzki DAL 77 2768.7 630 1314
## 12 NBA 2008 - 2009 Regular_Season Dirk Nowitzki DAL 81 3050.5 774 1616
## 13 NBA 2008 - 2009 Regular_Season Tony Parker SAS 72 2455.8 639 1263
## 14 NBA 2008 - 2009 Regular_Season Pau Gasol LAL 81 2999.3 592 1045
## 15 NBA 2009 - 2010 Regular_Season Dirk Nowitzki DAL 81 3038.8 720 1496
## 16 NBA 2010 - 2011 Regular_Season Dirk Nowitzki DAL 73 2503.9 610 1179
## 17 NBA 2010 - 2011 Regular_Season Pau Gasol LAL 82 3037.1 593 1120
## 18 NBA 2013 - 2014 Regular_Season Dirk Nowitzki DAL 80 2628.1 633 1273
## 19 NBA 2013 - 2014 Regular_Season Goran Dragic PHX 76 2668.0 552 1093
## 20 NBA 2015 - 2016 Regular_Season Andrew Wiggins MIN 81 2845.0 594 1294
## 21 NBA 2016 - 2017 Regular_Season Andrew Wiggins MIN 82 3048.4 709 1570
## 22 NBA 2018 - 2019 Regular_Season Nikola Jokic DEN 80 2503.9 616 1206
## 23 NBA 2018 - 2019 Regular_Season Luka Doncic DAL 72 2317.9 506 1186
## 24 NBA 2019 - 2020 Regular_Season Luka Doncic DAL 61 2047.3 581 1255
## X3PM X3PA FTM FTA TOV PF ORB DRB REB AST STL BLK PTS nationality
## 1 151 390 451 538 156 245 119 635 754 173 79 101 1784 Germany
## 2 139 350 440 516 145 222 120 635 755 186 83 77 1779 Germany
## 3 148 390 483 548 152 206 81 710 791 239 111 82 2011 Germany
## 4 1 10 416 565 213 220 192 528 720 229 34 148 1555 Spain
## 5 99 290 371 423 135 216 90 580 670 207 92 104 1680 Germany
## 6 91 228 615 708 176 219 96 661 757 240 97 119 2032 Germany
## 7 110 271 539 598 156 164 115 613 728 226 58 83 2151 Germany
## 8 3 12 425 617 235 184 191 522 713 371 46 153 1628 Spain
## 9 11 36 253 358 249 161 38 223 261 460 83 4 1510 France
## 10 72 173 498 551 167 171 122 571 693 263 52 62 1916 Germany
## 11 79 220 478 544 160 198 95 564 659 266 51 71 1817 Germany
## 12 61 170 485 545 157 176 88 593 681 197 61 63 2094 Germany
## 13 19 65 284 363 186 110 27 196 223 496 67 4 1581 France
## 14 1 2 343 439 157 172 262 518 780 284 52 81 1528 Spain
## 15 51 121 536 586 149 208 80 540 620 218 70 79 2027 Germany
## 16 66 168 395 443 137 172 50 463 513 190 38 47 1681 Germany
## 17 1 3 354 430 142 203 268 568 836 273 48 130 1541 Spain
## 18 131 329 338 376 117 165 40 458 498 216 73 45 1735 Germany
## 19 122 299 316 416 213 206 69 176 245 447 104 22 1542 Slovenia
## 20 57 190 430 565 182 165 107 186 293 164 78 46 1675 Canada
## 21 103 289 412 542 187 183 102 226 328 189 82 30 1933 Canada
## 22 83 270 289 352 248 228 228 637 865 580 108 55 1604 Serbia
## 23 168 514 346 485 247 137 86 477 563 429 77 25 1526 Slovenia
## 24 171 541 426 562 260 153 78 495 573 538 60 14 1759 Slovenia
#Distinct
basketball %>%
select(League:PTS, 'nationality') %>%
filter(PTS >= 1500, Player == 'Dirk Nowitzki') %>% distinct(FGM, FGA)
## FGM FGA
## 1 591 1247
## 2 600 1258
## 3 690 1489
## 4 605 1310
## 5 663 1445
## 6 751 1564
## 7 673 1341
## 8 630 1314
## 9 774 1616
## 10 720 1496
## 11 610 1179
## 12 633 1273
#Se hace la respectiva conversion de las columnas de tiros de media y tiros de tres a sus respectivos porcentajes #funcion group by $ summarise
basketball %>%
select(League:PTS, 'nationality') %>%
filter(PTS >= 1500, Player == 'Dirk Nowitzki') %>%
group_by(Season) %>%
reframe(two_point_percentage = (FGM*100)/FGA, three_point_percentage = (X3PM*100)/X3PA)
## # A tibble: 12 × 3
## Season two_point_percentage three_point_percentage
## <chr> <dbl> <dbl>
## 1 2000 - 2001 47.4 38.7
## 2 2001 - 2002 47.7 39.7
## 3 2002 - 2003 46.3 37.9
## 4 2003 - 2004 46.2 34.1
## 5 2004 - 2005 45.9 39.9
## 6 2005 - 2006 48.0 40.6
## 7 2006 - 2007 50.2 41.6
## 8 2007 - 2008 47.9 35.9
## 9 2008 - 2009 47.9 35.9
## 10 2009 - 2010 48.1 42.1
## 11 2010 - 2011 51.7 39.3
## 12 2013 - 2014 49.7 39.8
#Se organiza la informacion de mayor a menor en los tiros de media al ser los que proporcionalmente se intenta mas en el juego y se agrupa de acuerdo a la temporada #Funcion arrange
basketball %>%
select(League:PTS, 'nationality') %>%
filter(PTS >= 1500, Player == 'Dirk Nowitzki') %>%
group_by(Season) %>%
reframe(two_point_percentage = (FGM*100)/FGA, three_point_percentage = (X3PM*100)/X3PA) %>% arrange(desc(two_point_percentage), Season) %>%
head(12)
## # A tibble: 12 × 3
## Season two_point_percentage three_point_percentage
## <chr> <dbl> <dbl>
## 1 2010 - 2011 51.7 39.3
## 2 2006 - 2007 50.2 41.6
## 3 2013 - 2014 49.7 39.8
## 4 2009 - 2010 48.1 42.1
## 5 2005 - 2006 48.0 40.6
## 6 2007 - 2008 47.9 35.9
## 7 2008 - 2009 47.9 35.9
## 8 2001 - 2002 47.7 39.7
## 9 2000 - 2001 47.4 38.7
## 10 2002 - 2003 46.3 37.9
## 11 2003 - 2004 46.2 34.1
## 12 2004 - 2005 45.9 39.9
#Por ultimo, se puede observar que la mejor temporada de Dirk Norwitzki es la 2010-2011 en la cual salo campeon de la liga