-
Notifications
You must be signed in to change notification settings - Fork 3
/
functions.R
2009 lines (1876 loc) · 81.1 KB
/
functions.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
library(lubridate)
library(geosphere)
library(Rsymphony)
library(forecast);library(RCurl);library(slam);library(XML);library(RSelenium);
library(caret);library(doSNOW);library(rvest);library(robustbase);library(rpart);library(kernlab)
library(lpSolve);library(data.table);
library(reshape2);library(plyr);library(zoo);library(dplyr);library(RJSONIO)
library(ggplot2);library(glmnet);library(MASS);library(TTR)
library(Metrics)
options(stringsAsFactors=FALSE)
options(scipen=999)
#https://stackoverflow.com/questions/20495598/replace-accented-characters-in-r-with-non-accented-counterpart-utf-8-encoding
unwanted_array <- list( 'Š'='S', 'š'='s', 'Ž'='Z', 'ž'='z', 'À'='A', 'Á'='A', 'Â'='A', 'Ã'='A', 'Ä'='A', 'Å'='A', 'Æ'='A', 'Ç'='C', 'È'='E', 'É'='E',
'Ê'='E', 'Ë'='E', 'Ì'='I', 'Í'='I', 'Î'='I', 'Ï'='I', 'Ñ'='N', 'Ò'='O', 'Ó'='O', 'Ô'='O', 'Õ'='O', 'Ö'='O', 'Ø'='O', 'Ù'='U',
'Ú'='U', 'Û'='U', 'Ü'='U', 'Ý'='Y', 'Þ'='B', 'ß'='Ss', 'à'='a', 'á'='a', 'â'='a', 'ã'='a', 'ä'='a', 'å'='a', 'æ'='a', 'ç'='c',
'è'='e', 'é'='e', 'ê'='e', 'ë'='e', 'ì'='i', '??'='i', 'î'='i', 'ï'='i', 'ð'='o', 'ñ'='n', 'ò'='o', 'ó'='o', 'ô'='o', 'õ'='o',
'ö'='o', 'ø'='o', 'ù'='u', 'ú'='u', 'û'='u', 'ý'='y', 'ý'='y', 'é'='e')
coordName<-function(x){
x<-chartr(paste(names(unwanted_array), collapse=''),
paste(unwanted_array, collapse=''),
x)
#get rid of symobols
x<-gsub("\\s+$|^\\s+", "", x)
x<-gsub(", Jr.", " Jr.", x)
x<-gsub("[.]|[']|[,]|[’]|[?]", "", x)
x<-gsub(" Jr", "", x)
x<-gsub(" III", "", x)
x<-gsub(" IV", "", x)
x<-gsub(" II", "", x)
x<-gsub("-", " ", x)
x<-gsub(" ", " ", x)
x<-gsub("[*]", "", x)
x<-gsub("R J ", "RJ ", x)
x<-gsub("J J ", "JJ ", x)
x<-gsub("C J ", "CJ ", x)
x<-gsub("B J ", "BJ ", x)
x<-gsub("O J ", "OJ ", x)
x<-gsub("D J ", "DJ ", x)
x<-gsub("J P ", "JP ", x)
x[x=="Jacob Wiley"]<-"Jake Wiley"
x[grepl("Adnan Hodzi", x)]<-"Adnan Hodzic"
x[grepl("Stefan Jankovi", x)]<-"Stefan Jankovic"
x[x=="Josy Juan Barea"]<-"JJ Barea"
x[x=="Attarius Norwood"]<-"Attarrius Norwood"
x[x=="Orlando Mendez Valdez"]<-"Orlando Mendez"
x[x=="Keydren Clark"]<-"Kee Kee Clark"
x[x=="Norm Richardson"]<-"Norman Richardson"
x[x=="Abdul-Malik Abu"]<-"Abdul Malik Abu"
x[x=="Byron Mullens"]<-"BJ Mullens"
x[x=="James McAdoo"]<-"James Michael McAdoo"
x[x=="Kelly Oubre, Jr."]<-"Kelly Oubre"
x[x=="Le'Bryan Nash"]<-"LeBryan Nash"
x[x=="Tiny Gallon"]<-"Keith Gallon"
x[x=="Fabricio de Melo"|x=="Fabricio Melo"]<-"Fab Melo"
x[x=="Jose Manuel Calderon"]<-"Jose Calderon"
x[x=="Alexsander Vujacic"]<-"Sasha Vujacic"
x[grepl("l Gelabale", x)]<-"Mickael Gelabale"
x[x=="J J Hickson"]<-"JJ Hickson"
x[x=="C J Miles"]<-"CJ Miles"
x[x=="Sagana Diop"]<-"DeSagana Diop"
x[x=="Mengke Bateer"]<-"Bateer Mengke"
x[x=="Erik Jay Murphy"]<-"Erik Murphy"
x[x=="Sheldon Mac"]<-"Sheldon Mcclellan"
x[x=="Cliff Robinson"]<-"Clifford Robinson"
x[x=="Flip Murray"]<-"Ronald Murray"
x[x=="Efthimi Rentzias"]<-"Efthimios Rentzias"
x[x=="Ruben Boumtje"]<-"Ruben Boumtje-Boumtje"
x[x=="Maybyner Nene"]<-"Nene Hilario"
x[grepl("Maybyner", x)& grepl("Nene", x)]<-"Nene Hilario"
x[x=="Predrag Drobnjak"]<-"Peja Drobnjak"
x[x=="Anfernee Hardaway"]<-"Penny Hardaway"
x[x=="Slava Medvedenko"]<-"Stanislav Medvedenko"
x[x=="Charles Cornelius Smith"]<-"Charles Smith"
x[x=="Alek Radojevic"]<-"Aleksandar Radojevic"
x[x=="Wang Zhizhi"]<-"Zhizhi Wang"
x[x=="DJ Mbenga"]<-"Didier Ilunga-Mbenga"
x[x=="Frankie Williams"]<-"Frank Williams"
x[x=="Pooh Jeter"]<-"Eugene Jeter"
x[x=="Luigi Datome"]<-"Gigi Datome"
x[x=="Marcelo Huertas"]<-"Marcelinho Huertas"
x[x=="Ognjen Kuzmic"]<-"Ognen Kuzmic"
x[x=="Taurean Waller Prince"]<-"Taurean Prince"
x[x=="Randy Holcomb"]<-"Raed Farid Elhamali"
x[x=="Anthony Miller"]<-"Pig Miller"
x[x=="Carldell Johnson"]<-"Squeaky Johnson"
x[x=="Ibrahim Kutluay"]<-"Ibo Kutluay"
x[x=="Randy Holcomb"]<-"Raed Farid Elhamali"
x[x=="J R Giddens"]<-"JR Giddens"
x[x=="Alexsander Vujacic"]<-"Sasha Vujacic"
x[x=="Oluwafemi Ibikunle"]<-"Femi Ibikunle"
x[x=="Carlos Lopez Sosa"]<-"Carlos Lopez"
x[x=="Youssoupha Mbao"]<-"Yous Mbao"
x[x=="Adrien Coleman"]<-"Adrian Coleman"
x[x=="Adonis Delarosa"|x=="Joe De La Rosa"]<-"Joey De La Rosa"
x[x=="Svi Mykhailiuk"]<-"Sviatoslav Mykhailiuk"
x[x=="Sheldon Mclellan"]<-"Sheldon Mcclellan"
x[x=="Trevon Blueitt"]<-"Trevon Bluiett"
x<-gsub("Joshua ", "Josh ", x)
x<-gsub("Boubecar ", "Boubacar ", x)
x<-gsub("Gabe ", "Gabriel ", x)
x<-gsub("Scottie |Scotty ", "Scott ", x)
x<-gsub("Gabe ", "Gabriel ", x)
x<-gsub("Rayshawn |Raymond |Rayes ", "Ray ", x)
x<-gsub("SirDominic |Dominic |Dominitrix |Dominique ", "Dom ", x)
x<-gsub("Langendoerfer", "Langendoefer", x)
x<-gsub("Mohamed", "Mohammed", x)
x<-gsub("JaQuan", "Jaquan", x)
x<-gsub("Demarcus |DaMarcus |Damarcus ", "DeMarcus ", x)
x<-gsub("Dwan ", "Dwon ", x)
x<-gsub("Jamal |Jaamal ", "Jamaal ", x)
x<-gsub("Octavious ", "Octavius ", x)
x<-gsub("Malcom", "Malcolm", x)
x<-gsub("Darrington ", "Darington ", x)
x<-gsub("Kenechukwu ", "Kene ", x)
x<-gsub("Gene |Geno ", "Eugene ", x)
x<-gsub("Rasheen ", "Rasheem ", x)
x<-gsub("Lew ", "Lewis ", x)
x<-gsub("Hasaan ", "Hassan ", x)
x[x=="Kahlil Ahmad"]<-"Khalil Ahmad"
x[x=="Derek Funderburk"]<-"Dj Funderburk"
x[x=="Rechon Black"]<-"Leaky Black"
x[x=="Tamell Pearson"]<-"Tamell Peason"
x[x=="Deshang Williams Weaver"| grepl("g Williams Weaver", x)]<-"Dj Weaver"
x[x=="Ty Mosely"]<-"Tyronn Mosley"
x[x=="Aristide Boya"]<-'Ari Boya'
x[x=="Rodgerick Brown"]<-"Rod Brown"
x[x=="Ezekiel Richards"]<-"Zeke Richards"
x[x=="Shaun Williams"]<-"Shaun Neal Williams"
x[x=="Jermaine Couisnard"]<-"Jermaine Cousinard"
x[x=="Sam Froling"]<-"Samson Froling"
x[x=="Torrence Watson"]<-"Torrance Watson"
x[x=="Jake Forrester"]<-"Jakob Forrester"
x[x=="Immanuel Bates"]<-"Manny Bates"
x[x=="Luguentz Dort"]<-"Lugentz Dort"
x[x=="Nazreon Reid"]<-"Naz Reid"
x[x=="Simisola Shittu"]<-"Simi Shittu"
x[x=="Reggie Garnder"]<-"Reggie Gardner"
x[x=="Karlis Silis"]<-"Karlis Silins"
x[x=="Domen Omladi"]<-"Domen Omladic"
x[x=="Abdulsalam Sarki"]<-"Abdul Sarki"
x[x=="Elijah Gonzalez"]<-"Elijah Gonzales"
x[x=="Anthony Perez Cortesia"]<-"Anthony Perez"
x[x=="Johan Van Zegeren"]<-"Joey van Zegeren"
x[x=="Jamie Crockett"]<-"Jamee Crockett"
x[x=="Charles Gavin"]<-"Chuck Gavin"
x[x=="Achraf Yacoubou"]<-"Ash Yacoubou"
x[x=="Darwin Davis"]<-"Dee Davis"
x[x=="Sergey Lishchuk"]<-"Sergei Lishouk"
x[x=="Sergey Monya"]<-"Sergei Monia"
x[x=="Louis Amundson"]<-"Lou Amundson"
x[x=="Denis Alibegovi"]<-"Denis Alibegovic"
x[x=="Deonte Burton Nv"]<-"Deonte Burton"
x[x=="Gary Payton Ii"]<-"Gary Payton"
x[x=="Robert Hubbs III"]<-"Robert Hubbs"
x[x=="Glenn Robinson Iii"]<-"Glenn Robinson"
x[x=="Derek Semanas"]<-"Derek Semenas"
x[x=="Collin Reddick"]<-"Colin Reddick"
x[x=="Jmison Morgan"]<-"JMison Morgan"
x[x=="Isaac Austin"]<-"Ike Austin"
x[x=="Isaac Fontaine"]<-"Ike Fontaine"
x[x=="Mo Bamba"]<-"Mohammed Bamba"
x[x=="Moe Wagner"]<-"Moritz Wagner"
x[x=="Sheldon Mclellan"]<-"Sheldon Mac"
x[x=="Isaiah Rider"]<-"Jr Rider"
x[x=="Robert Hubbs III"]<-"Robert Hubbs"
x[x=="Bawa Muniri"| x=="Bawa Muniru"|x=="Muniri Bawa"]<-"Muniru Bawa"
x[x=="Rich McBride"]<-"Richard McBride"
x[x=="Cat Barber"]<-"Anthony Barber"
x[x=="Alter Gilbert"]<-"Alterique Gilbert"
x[x=="Tiny Gallon"]<-"Keith Gallon"
x[x=="Mike Dunigan"]<-"Michael Dunigan"
x[grepl("Corperryale", x) &grepl("Harris", x)]<-"Manny Harris"
x[x=="Mike Dunigan"]<-"Michael Dunigan"
x[x=="Cameron Biedscheid"]<-"Cam Biedscheid"
x[x=="Wink Adams"]<-"Jovan Adams"
x[x=="Ky Madden"]<-"Rashad Madden"
x[x=="Marquise Kately"]<-"Marquis Kately"
x[x=="Drew Lavender"]<-"Andrew Lavender"
x[x=="Chris Douglas-Roberts"|grepl("Douglas Roberts", x)]<-"Chris Douglas Roberts"
x[x=="Brenton Petway"]<-"Brent Petway"
x[x=="Andrew White III"]<-"Andrew White"
x[x=="M Kidd Gilchrist"|x=="Michael Gilchrist"]<-"Michael Kidd Gilchrist"
x[x=="Ricardo Ledo"]<-"Ricky Ledo"
x[x=="K Caldwell Pope"]<-"Kentavious Caldwell Pope"
x[x=="C Douglas Roberts"]<-"Chris Douglas Roberts"
x[x=="M Carter Williams"]<-"Michael Carter Williams"
x[x=="R Hollis Jefferson"]<-"Rondae Hollis Jefferson"
x[x=="Nick Stauskas"]<-"Nik Stauskas"
x[x=="Pierre Niles"]<-"Pierre Henderson"
x[x=="Bill Walker"]<-"Henry Walker"
x[x=="Jalyn Pennie"]<-"Jayln Pennie"
x[x=="Augustus Gilchrist"]<-"Gus Gilchrist"
x[x=="Augustin Rubit"]<-"Augustine Rubit"
x[x=="Juan Toscano"]<-"Juan Anderson"
x[x=="Akini Akini"]<-"Akini Adkins"
x[x=="Kevin Sam Hunt"]<-"Sam Hunt"
x[x=="Isaiah Grayson"]<-"Issiah Grayson"
x[x=="JT Miller"]<-"James Miller"
x[grepl("Marko Pirovi", x)]<-"Marko Pirovic"
x[x=="Chukwudubem Duby Okeke"]<-"Duby Okeke"
x[x=="Kendell Ramlal"]<-"Kendall Ramlal"
x[x=="Andre Gillette"]<-"Scooter Gillette"
x[x=="Rahlir Jefferson"]<-"Rahlir Hollis Jefferson"
x[x=="Jontaveous Sulton"]<-"JT Sulton"
x[x=="CJ Jackson"|x=="Cj Jackson"]<-"Charles Jackson"
x[x=="Joseph Young"]<-"Joe Young"
x[x=="Alejandro Carmona Sanchez"]<-"Alex Carmona"
x[x=="Will Tchiengang"|x=="William Tchiengang"]<-"William Tchiengang Tanko"
x[x=="Nuwriyl Williams"]<-"New Williams"
x[x=="Snap Peters"]<-"Brandon Peters"
x[x=="Royce O'Neal"|x=="Royce ONeal"]<-"Royce O'Neale"
x[grepl("Kissoonlal", x)]<-"Reginald Kissoonlal"
x[grepl("Lukas Berg", x)]<-"Lukas Bergang"
x[x=="Karl Towns"]<-"Karl Anthony Towns"
x[x=="Demond Carter"]<-"Tweety Carter"
x[x=="Ping Shang"]<-"Shang Ping"
x[x=="Paul Jorgensen"]<-"Paul Jorgenson"
x[x=="Michael Milligan"]<-"Boo Milligan"
x[x=="Kristiyan Stavrev"]<-"Kiko Stavrev"
x[x=="Harrison Mackenzie Smith"]<-"Harrison Smith"
x[x=="Vasilije Pusica"]<-"Vasa Pusica"
x[x=="Bryant Searcy"]<-"Junior Searcy"
x[x=="Cleveland Thomas"]<-"Pancake Thomas"
x[x=="Shaun Willett"]<-"Shawn Willett"
x[x=="Nikola Scekic"]<-"Nikola Scekic"
x[x=="Elvar Friiriksson"]<-"Elvar Fridriksson"
x[x=="Joell Hopkins"]<-"Joel Hopkins"
x[x=="Antonio Toplyn"]<-"Tony Toplyn"
x[x=="Jere Vucica"]<-"Jere Vucica"
x[x=="Alex Shepard"]<-"Alex Sheppard"
x[x=="Babajide Aina"]<-"Babajidne Aina"
x[x=="Cory Arentsen"]<-"Corey Arentsen"
x[x=="Quinten Bastian"]<-"Quentin Bastian"
x[x=="Ude Ifeanyichukwu"]<-"Ude Ifeanyichukwa"
x[x=="Deonta Jethroe"]<-"Dj Jethroe"
x[x=="Daouda Berete"]<-"David Berete"
x[x=="Aaryngston Bibens"]<-"Aary Bibens"
x[x=="Burroughs Cook"]<-"Johnathan Cook"
x[x=="Kermal Dincer"]<-"Kemal Dincer"
x[x=="Terence Johnson"]<-"Terrance Johnson"
x[x=="Andrew Smeathers"]<-"Andy Smeathers"
x[x=="Torlof Thomas"]<-"Torlorf Thomas"
x[x=="Hidde Vos"]<-"Hidde Arjans Vos"
x[x=="Prince Arceneaux"]<-"Prince Arceneux"
x[x=="Clayton Cowell"]<-"Dom Cowell"
x[x=="Ifeanyi Eke"]<-"Ife Eke"
x[x=="Simuel Frazier"]<-"Sim Frazier"
x[x=="Rayner Fredrick"]<-"Ray Fredrick"
x[x=="Isaac Freeman"]<-"Izzy Freeman"
x[x=="Volodymyr Gerun"]<-"Volodymyr Herun"
x[x=="Jarrell Lane"]<-"Jarrel Lane"
x[which(startsWith(x, "Mike "))]<-gsub("Mike ", "Michael ", x[which(startsWith(x, "Mike "))])
x[which(startsWith(x, "Mo "))]<-gsub("Mo ", "Maurice ", x[which(startsWith(x, "Mo "))])
x[which(startsWith(x, "Joseph "))]<-gsub("Joseph ", "Joe ", x[which(startsWith(x, "Joseph "))])
x[which(startsWith(x, "Joey "))]<-gsub("Joey ", "Joe ", x[which(startsWith(x, "Joey "))])
x[which(startsWith(x, "Erkam K"))]<-"Erkam Kiris"
x<-gsub("Gregory |Gregg ", "Greg ", x)
x<-gsub("Mitchell ", "Mitch ", x)
x<-gsub("Micheal ", "Michael ", x)
x<-gsub("Rashad ", "Rashaad ", x)
x<-gsub("Enrico ", "Rico ", x)
x<-gsub("Giovanni ", "Gio ", x)
x<-gsub("Khalill ", "Khalil ", x)
x<-gsub("Nicholas |Nic |Nicolas |Nickolas ", "Nick ", x)
x<-gsub("Dame |Damien ", "Damian ", x)
x<-gsub("William ", "Will ", x)
x<-gsub("Timothy ", "Tim ", x)
x<-gsub("Herb ", "Herbert ", x)
x<-gsub("Christian |Christopher ", "Chris ", x)
x<-gsub("Phillip |Philip ", "Phil ", x)
x<-gsub("Wesley ", "Wes ", x)
x<-gsub("Qise ", "Marqise ", x)
x<-gsub("Vic ", "Victor ", x)
x<-gsub("Rodrick ", "Rod ", x)
x<-gsub("Denzell ", "Denzel ", x)
x<-gsub("Edward |Eddy |Eddie ", "Ed ", x)
x<-gsub("Zach |Zack |Zachery |Zakarie |Zak |Zac ", "Zachary ", x)
x<-gsub("Sam |Samuel |Sammie |Sammy ", "Sam ", x)
x<-gsub("Steve |Stevie ", "Steven ", x)
x<-gsub("Dan |Danny ", "Daniel ", x)
x<-gsub("Dave ", "David ", x)
x<-gsub("Ayodele ", "Dele ", x)
x<-gsub("Brad ", "Bradley ", x)
x<-gsub("Tyrone |Tyquone ", "Ty ", x)
x<-gsub("Bobby ", "Bob ", x)
x<-gsub("Cedrick ", "Cedric ", x)
x<-gsub("Gabiriel ", "Gabe ", x)
x<-gsub("Kenny |Kenneth ", "Ken ", x)
x<-gsub("Joshua |Joshia ", "Josh ", x)
x<-gsub("Ishmael |Ishmail ", "Ish ", x)
x<-gsub("Cameron ", "Cam ", x)
x<-gsub("Douglas ", "Doug ", x)
x<-gsub("Kameron ", "Kam ", x)
x<-gsub("Braiden ", "Braden ", x)
x<-gsub("Leonidas ", "Leo ", x)
x<-gsub("Matthew |Matth ", "Matt ", x)
x<-gsub("Nathaniel |Nathan ", "Nate ", x)
x<-gsub("Jeffrey |Jeffery ", "Jeff ", x)
x<-gsub("Franklin ", "Frank ", x)
x<-gsub("Pat ", "Patrick ", x)
x<-gsub("Alexander |Alexandru ", "Alex ", x)
x<-gsub("Ron |Ronnie ", "Ronald ", x)
x<-gsub("Walter ", "Walt ", x)
x<-gsub("A J ", "AJ ", x)
x<-gsub("Shaq |Shaquil |Shaquiell |Shaqueille |Shaqil |Shaquile ", "Shaquille ", x)
x<-gsub("Tywon ", "Ty ", x)
x<-gsub("Peter ", "Pete ", x)
x<-gsub("Vincent ", "Vince ", x)
x<-gsub("Issac |Isacc ", "Isaac ", x)
x<-gsub("Roderick |Rodney ", "Rod ", x)
x<-gsub("Bennie |Ben ", "Benjamin ", x)
x<-gsub("Robbie |Robby |Rob ", "Robert ", x)
x<-gsub("^Jonathan |^Jon |^Johnny |^John |^Johnathan |^Jonathon ", "Jonathan ", x)
x<-gsub("Darris |Darrius ", "Darius ", x)
x<-gsub("Darquavis ", "Dar ", x)
x<-gsub("Eneil ", "Eniel ", x)
x<-gsub("Kashiff ", "Kashif ", x)
x<-gsub("Max ", "Maxwell ", x)
x<-gsub("Terrence |Terance |Terence ", "Terrance ", x)
x<-gsub("Kalvin ", "Kal ", x)
x<-gsub("Markieth ", "Markeith ", x)
x<-gsub("Thomas ", "Tom ", x)
x<-gsub("Kurtis ", "Kurt ", x)
x<-gsub("Javi ", "Javier ", x)
x<-gsub("Joey ", "Joe ", x)
x<-gsub("Jontavious ", "Johntavius ", x)
x[grepl("Brandis Raley", x)]<-"Brandis Raley Ross"
x[x=="Lakendric Longmier"]<-"Lakendric Longmire"
x[x=="Antonio Lang"]<-"Tj Lang"
x[x=="Ricardo Brown"]<-"Josh Brown"
x[x=="Terrell Holloway"]<-"Tu Holloway"
x[x=="Krystopher Faber"]<-"Krys Faber"
x[x=="Jin Soo Kim"]<-"Jin Soo Choi"
x[x=="Sean Carter"]<-"Sean Roosevelt Carter"
x[x=="Antiquan Beckham"]<-"Twany Beckham"
x[x=="Gaby Ngoundgo"]<-"Gaby Ngoundjo"
x[x=="Robo Kreps"]<-"Robert Kreps"
x[x=="Elliot Engelmann"]<-"Elliot Englemann"
x[x=="Andrew Ogilvy"]<-"AJ Ogilvy"
x[x=="Bassy Inameti"]<-"Bassey Inameti"
x[x=="Gerald Inman"]<-"JR Inman"
x[x=="Trae Goldstan"]<-"Trae Goldston"
x[x=="Derrick Rivera"]<-"DJ Rivera"
x[x=="George Fotso"]<-"Georges Fotso"
x[grepl("Szymon Szewczyk", x)]<-"Szymon Szewczyk"
x[x=="George Fotso"]<-"Georges Fotso"
x[x=="George Massoda"]<-"Georges Massoda"
x[x=="Dashan Harris"]<-"Dash Harris"
x[x=="Darren Govens"]<-"Darrin Govens"
x[x=="Desean Butler"|x=="DeSean Butler"]<-"Dasean Butler"
x[x=="Cory Pflieger"]<-"Cory Pfleiger"
x[x=="Colby Santos"]<-"Colbey Santos"
x[x=="Shamaine Dukes"]<-"Joe Dukes"
x[x=="Terrance Woodberry"]<-"Terrance Woodbury"
x[x=="Sharaud Curry"]<-"Morris Curry"
x[x=="Kent Tribbett"]<-"Kenny Tribbett"
x[x=="Jamar Thorpe"]<-"Jahmar Thorpe"
x[x=="Donald Rashaad Singleton"]<-"Rashaad Singleton"
x[x=="Arminus Urbutis"]<-"Arminas Urbutis"
x[grepl("Benas Gric", x)]<-"Benas Griciunas"
x[x=="Miguel Millien"]<-"Slim Millien"
x[x=="Chamberlain Oguchi"]<-"Champ Oguchi"
x[x=="Wil Fameni"]<-"Wilfried Fameni"
x[iconv(x, to="ASCII//TRANSLIT")=="Marko A?uze"]<-"Marko Cuze"
x[iconv(x, to="ASCII//TRANSLIT")=="Nikola SA?ekiA?"]<-"Nikola Scekic"
x[x=="Weyinmi Efejuku"]<-"Weyinmi Efejuku Rose"
x[x=="Stevie Thompson"]<-"Stephen Thompson"
x[x=="Elbert Robinson III"]<-"Elbert Robinson"
x[x=="Marcus E Williams"]<-"Marcus Williams"
x[x=="Steven Thompson"| x=="Stevie Thompson"|x=="Stephen Thompson"]<-"Stephen Thompson"
x[x=="Mitch Worchester"]<-"Mitch Worcester"
x[x=="Jarod Sam"]<-"Jared Sam"
x[x=="Steven Albrecht"]<-"Stephen Albrecht"
x[x=="Mycheal Henry"]<-"Myke Henry"
x[x=="Mykhael Lattimore"]<-"Myke Lattimore"
x[x=="Kevin Ferrell"]<-"Yogi Ferrell"
x[x=="Reginald Becton"]<-"Reginald Buckner"
x[x=="E C Matthews"]<-"Ec Matthews"
x[x=="Rod Simean"]<-"Rod Simeon"
x[x=="Ike Smith"]<-"Ikeon Smith"
x[x=="Reginal Johnson"]<-"Reginald Johnson"
x[x=="Domas Sabonis"]<-"Domantas Sabonis"
x[x=="Arnaud William Adala Moto"|x=="Arnaud Adala Moto"]<-"Arnaud Moto"
x[x=="Tum Tum Nairn"]<-"Lourawls Nairn"
x[x=="Montaque Gill Ceasar"]<-"Montaque Gill Caesar"
x[x=="Chicken Knowles"]<-"Danrad Knowles"
x[x=="Pierre Henderson Niles"]<-"Pierre Henderson"
x[x=="Marquez Haynes"]<-"Keith Haynes"
x[x=="Moe Harkless"]<-"Maurice Harkless"
x[x=="Donnovan Kirk"]<-"Donnavan Kirk"
x[x=="Lorenzo Mata Real"]<-"Lorenzo Mata"
x[x=="Michael Cage"]<-"Mj Cage"
x[x=="Baden Jaxen"]<-"Dexter Strickland"
x[x=="Perry Dozier"]<-"PJ Dozier"
x[x=="Antonio Wilson"]<-"Tony Wilson"
x[x=="Jinski Grigsby"]<-"Trajinski Grigsby"
x[x=="Papa Samba Ndao"]<-"Papa Ndao"
x[x=="Daryus Quarles"]<-"Darius Quarles"
x[x=="Devonte Drinkard"]<-"Davante Drinkard"
x[grepl("Von", x) & grepl("Wafer", x)]<-"Von Wafer"
x[x=="Faisal Aden"]<-"Faisel Aden"
x[x=="Trevan Abraham"]<-"Travon Abraham"
x[x=="Darell Haley"]<-"DJ Haley"
x[x=="Tony Parker (ga)"|x=="Tony Parker (GA)"]<-"Tony Parker"
x[x=="Justin Jackson (canada)"|x=="Justin Jackson (Canada)"]<-"Justin Jackson"
x[x=="Craig Sealy"]<-"Craig Sealey"
x[x=="Demarquise Johnson"]<-"Que Johnson"
x[x=="Anrio Adams"]<-"Rio Adams"
x[x=="Andre Applewhite"]<-"Dre Applewhite"
x[x=="DeQuavious Wagner"]<-"Dee Wagner"
x[x=="Maurice Watson"]<-"Mo Watson"
x[x=="Nkereuwem Okoro"]<-"Kerwin Okoro"
x[x=="Nazareth Long"]<-"Naz Long"
x[x=="Kendal Yancy"]<-"Kendal Yancy Harris"
x[x=="Wannah Bail"]<-"Wanaah Bail"
x[x=="Bryce Dejean Jones"]<-"Bryce Jones"
x[x=="Ikenna Iroegbu"]<-"Ike Iroegbu"
x[x=="Byron Zeigler"|x=="Byron Bo Zeigler"]<-"Bo Zeigler"
x[x=="Jarius Lyles"]<-"Jairus Lyles"
x[x=="Rashawn Powell"|x=="RaShawn Powell"]<-"Pookie Powell"
x[x=="Soma Edo"]<-"Karachi Edo"
x[x=="Jalen Coleman"]<-"Jalen Coleman Lands"
x[x=="Luke Garza"]<-"Luka Garza"
x[x=="Ahmed Fields"]<-"Ahmad Fields"
x[x=="Manu Lecomte"]<-"Emmanuel Lecomte"
x[x=="Lucas Meikle"]<-"Luke Meikle"
x[x=="Wadley Mompremeir"]<-"Wadly Mompremier"
x[x=="Janari Joesarr"]<-"Janari Joesaar"
x[x=="Idrissa Diallo"]<-"Idy Diallo"
x[x=="Nick Babb"]<-"Nick Weiler Babb"
x[x=="Jeremiah Paige"]<-"JD Paige"
x[x=="Joseph Toye"]<-"Joe Toye"
x[x=="Bakari Evelyn"]<-"Baker Evelyn"
x[x=="Jonathan Laurent"]<-"Jonathan Jean Laurent"
x[x=="Joseph Strugg"|x=="Joseph Struggs"]<-"Joe Srugg"
x[x=="Christ Koumadje"]<-"Jean Marc Christ Koumadje"
x[x=="Ahmad Carver"]<-"Ahmad Caver"
x[x=="Enrico Tucker"]<-"Rico Tucker"
x[x=="Richard Dorsey"]<-"Joe Dorsey"
x[x=="Aleksander Maric"]<-"Aleks Maric"
x[x=="Gordan Watt"]<-"Gordon Watt"
x[x=="Jamall Edmonson"]<-"Jamall Edmondson"
x[x=="Artavis Fisher"]<-"Tay Fisher"
x[x=="Tangueray Beavers"]<-"Tank Beavers"
x[x=="Artavis Fisher"]<-"Tay Fisher"
x[x=="Laimonas Kisielius"]<-"Laimis Kisielius"
x[x=="Bret Loscalzo"]<-"Brett Loscalzo"
x[x=="Juan Pablo Silveira"]<-"Juan Pablo"
x[x=="Gyno Pomare"]<-"Leonardo Pomare"
x[grepl("Abu", x)& grepl("Arisha", x)]<-"Mohammed Abuarisha"
x[x=="Erik Flato"]<-"Eric Flato"
x[x=="Abdul Herrera"]<-"Abdul Hererra"
x[x=="Micka?l Pietrus"]<-"Mickael Pietrus"
x[x=="Anderson Varej?o"]<-"Anderson Varejao"
x[x=="Zaur Pachulia"]<-"Zaza Pachulia"
x[x=="Leandro Barbosa"]<-"Leandrinho Barbosa"
x[x=="Rafael Araujo"]<-"Babby Araujo"
x[x=="Pavel Podkolzine"]<-"Pavel Podkolzin"
x[x=="Xue Yuyang"]<-"Yuyang Xue"
x[x=="Pete Ramos"]<-"Pete Jonathan Ramos"
x[x=="Rickey Paulding"]<-"Ricky Paulding"
x[x=="Lou Williams"]<-"Louis Williams"
x[x=="M Andriuskevicius"]<-"Martynas Andriuskevicius"
x[x=="Micka?l Gelabale"]<-"Mickael Gelabale"
x[x=="Cheik Samb"|x=="Cheick Samb"|x=="Cheikh Samb"]<-"Cheickh Samb"
x[x=="Marcus Vinicus"]<-"Marquinhos Vinicius"
x[x=="Deitrich Cole"]<-"Dietrich Cole"
x[x=="Olexsiy Pecherov"]<-"Oleksiy Pecherov"
x[x=="Anderson Varej?o"]<-"Anderson Varejao"
x[x=="Tre Hansbrough"]<-"Tre Hansborough"
x[x=="Aaron Afflalo"]<-"Arron Afflalo"
x[x=="Giorgos Printezis"]<-"Georgios Printezis"
x[x=="Yi Jianlian"]<-"Jianlian Yi"
x[x=="Sun Yue"]<-"Yue Sun"
x[x=="D J Strawberry"]<-"DJ Strawberry"
x[grepl("Mbah aMou| A Moute| a Moute", x)|x=="LR Mbah"]<-"Luc Mbah a Moute"
x[x=="Danilo Pinnock"]<-"JR Pinnock"
x[x=="Chukwudiebere Maduabum"]<-"Chu Maduabum"
x[x=="AlFarouq Aminu"]<-"Al-Farouq Aminu"
x[x=="Patrick Mills"]<-"Patty Mills"
x[x=="Sergi Llull"]<-"Sergio Llull"
x[x=="Sergiy Gladyr"|x=="Sergey Gladyr"]<-"Sergii Gladyr"
x[x=="Alexy Shved"]<-"Alexey Shved"
x[x=="Christiano Felicio"]<-"Cristiano Felicio"
x[x=="Ifeanyi Umezurike"]<-"Ifyeani Umezurike"
x[x=="Roy Devyn Marble"]<-"Devyn Marble"
x[x=="Sergiy Gladyr"]<-"Sergii Gladyr"
x[x=="Avery Ugba"]<-"Averyl Ugba"
x[x=="Vyacheslav Kravtsov"|x=="Slava Kravtsov"]<-"Viacheslav Kravtsov"
x[x=="Nando DeColo"]<-"Nando De Colo"
x[x=="Darius JohnsonOdom"]<-"Darius Johnson-Odom"
x[x=="Atar Majok"]<-"Ater Majok"
x[x=="Michael KiddGilchrist"]<-"Michael Kidd-Gilchrist"
x[x=="Targuy Ngombo"]<-"Tanguy Ngombo"
x[x=="Dennis Schroeder"]<-"Dennis Schroder"
x[x=="Giannis Adetokunbo"|x=="Giannis Adetokoubo"]<-"Giannis Antetokounmpo"
x[x=="Kentavious CaldwellPope"]<-"Kentavious Caldwell-Pope"
x[x=="Michael CarterWilliams"]<-"Michael Carter-Williams"
x[x=="Livio JeanCharles"]<-"Livio Jean-Charles"
x[x=="Walter Tavares"]<-"Edy Tavares"
x[x=="Nemanja Zubac"]<-"Nemanja Zubec"
x[x=="Raul Neto"]<-"Raulzinho Neto"
x[x=="Vasilije Micic"]<-"Vasilje Micic"
x[x=="Willie CauleyStein"]<-"Willie Cauley-Stein"
x[x=="Rondae HollisJefferson"]<-"Rondae Hollis-Jefferson"
x[x=="Oliver Hanlan"]<-"Olivier Hanlan"
x[x=="Juan Hernangomez"]<-"Juancho Hernangomez"
x[x=="Guillermo Hernangomez"]<-"Willy Hernangomez"
x[x=="Sasha Pavlovic"]<-"Aleksandar Pavlovic"
x[x=="Marcus Vinicius"]<-"Marquinhos Vinicius"
x[x=="Georgios Papagiannis"]<-"George Papagiannis"
x[x=="Mouhamed SaerSene"|x=="Mouhamed Sene"]<-"Saer Sene"
x[x=="Jaun Vaulet"]<-"Juan Vaulet"
x[x=="Kahlil Felder"]<-"Kay Felder"
x[x=="Timothe Luwawu"]<-"Timothe Luwawu-Cabarrot"
x[x=="Edrice Adebayo"]<-"Bam Adebayo"
x[x=="Jeff Pendergraph"]<-"Jeff Ayres"
x[x=="Juan Jose Barea"|x=="Jose Barea"]<-"JJ Barea"
x[x=="Dorian FinneySmith"]<-"Dorian Finney-Smith"
x[x=="OG Anunoby"|x=="Og Anunoby"]<-"Ogugua Anunoby"
x[x=="Abdul Herrera"]<-"Abdul Hererra"
x[x=="Miles Guidry"]<-"Myles Guidry"
x[x=="Adam Walther"]<-"Bubba Walther"
x[x=="Emmanuel Willis"]<-"Emanuel Willis"
x[x=="Walter Waters"]<-"Walt Waters"
x[x=="Stefan Jackson"]<-"Stefon Jackson"
x[x=="Nayal Koshwal"]<-"Mac Koshwal"
x[x=="Antonio Jardine"]<-"Scoop Jardine"
x[x=="Shai Gilgeous Alexander"]<-"Shai Alexander"
x[x=="Howard Thompkins"]<-"Trey Thompkins"
x[x=="Demarquis Bost"]<-"Dee Bost"
x[x=="Jajuan Johnson Purdue"|x=="JaJuan Johnson (Purdue)"]<-"Jajuan Johnson"
x[x=="James Mcadoo"]<-"James Michael Mcadoo"
x[x=="Arron "]<-"Arron Afflalo"
x[x=="Demarquis Bost"]<-"Dee Bost"
x[x=="Dezmine Wells"]<-"Dez Wells"
x[x=="Elijah Carter"]<-"Eli Carter"
x[x=="Ricardo Gathers"]<-"Rico Gathers"
x[x=="Zam Fredrick"]<-"Zam Frederick"
x[x=="Hanner Perea"]<-"Hanner Mosquera-Perea"
x[x=="Jethro Tshisumpa Mbiya"]<-"Jethro Tshisumpa"
x[x=="Marcus Georges Hunt"]<-"Marcus Hunt"
x[x=="Fred Van Vleet"]<-"Fred VanVleet"
x[x=="Dayshon Smith"]<-"Scoochie Smith"
x[x=="Romelo Trimble"]<-"Melo Trimble"
x[x=="Keelon Lawson"]<-"KJ Lawson"
x[x=="Marcus D Williams"]<-"Marcus Williams"
x[x=="Tj Gibbs"|x=="TJ Gibbs"]<-"Temple Gibbs"
x[x=="Levan Alston"]<-"Shizz Alston"
x[x=="Edwin Rios"]<-"Ed Rios"
x[x=="Tyrell Reed"]<-"Tyrel Reed"
x[x=="Carlton Scott"]<-"Carleton Scott"
x[x=="James Hickson"]<-"JJ Hickson"
x[x=="Clinton Chapman"]<-"Clint Chapman"
x[x=="Martavious Adams"]<-"Martavius Adams"
x[x=="Elijah Holman"]<-"Eli Holman"
x[x=="Robin Sikes"]<-"Rob Sikes"
x[x=="Kenechukwu Obi"]<-"Kene Obi"
x[x=="Rayford Shipman"]<-"Ray Shipman"
x[x=="Wallace Judge"]<-"Wally Judge"
x[x=="Johnnie Williams"]<-"Johnnny Williams"
x[x=="Thomas Knight"]<-"Tom Knight"
x[x=="Andre Horne"]<-"Andrew Horne"
x[x=="Eric Hutchinson"]<-"Eric Hutchison"
x[x=="Gorgui Sy Dieng"]<-"Gorgui Dieng"
x[x=="Jan Maehlan"]<-"Jan Maehlen"
x[x=="Daniel Sapp"]<-"TJ Sapp"
x[x=="Jarrell Eddie"]<-"Jarell Eddie"
x[x=="Devonte Abron"]<-"Devonta Abron"
x[x=="Kyle Caudill"]<-"KC Caudill"
x[x=="Geoffrey Groselle"]<-"Geoff Groselle"
x[x=="Isaac Nielson"]<-"Isaac Neilson"
x[x=="Ray Lee"]<-"Raven Lee"
x[x=="Willie Cauley"]<-"Willie Cauley Stein"
x[x=="Ifeany Onyekaba"]<-"Ifeanyi Onyekaba"
x[x=="Boris Bojanovsky"]<-"Boris Bojanovski"
x[x=="Rashawn Powell"]<-"Pookie Powell"
x[x=="Jarrell Martin"]<-"Jarell Martin"
x[x=="Tony Trocha"]<-"Tonny Trocha-Morelos"
x[x=="Emmanuel Ezechinoso"]<-"Emmanuel Ezechinonso"
x[x=="Clay Custer"]<-"Clayton Custer"
x[x=="Davon Chuck Ester"]<- "Chuck Ester"
x[x=="Jalen Benton"]<- "Jaylen Benton"
x[x=="Anas Osama Mahmoud"|x=="Anas Osama"]<-"Anas Mahmoud"
x[x=="Jacob Hammond"]<-"Jake Hammond"
x[x=="Austin Gillman"]<-"Austin Gillmann"
x[x=="Derek Pardon"]<-"Dererk Pardon"
x[x=="Semir Sehic"]<-"Samir Sehic"
x[x=="Jailon Miller"|x=="Jalon Miller"|x=="Jalion Miller"]<-"JD Miller"
x[x=="Cheickna Dembele"]<-"Cheikna Dembele"
x[x=="Jacob Hammond"]<-"Jake Hammond"
x[grepl("Trae", x)& grepl(" Jefferson", x)]<-"Demontrae Jefferson"
#redo
x<-gsub(", Jr.", " Jr.", x)
x<-gsub("[.]|[']|[,]", "", x)
x<-gsub(" Jr", "", x)
x<-gsub(" III", "", x)
x<-gsub(" IV", "", x)
x<-gsub(" II", "", x)
x<-gsub("-", " ", x)
x<-gsub(" ", " ", x)
x<-sapply(x, simpleCap)
x<-as.character(x)
x<- unname(x)
x<-gsub("T J", "Tj", x)
x[x=="NANA"]<-NA
x[grepl("Owens V", x)]<-"Clemmye Owens"
x[x=="Drekalo Clayton"]<-"Dre Clayton"
x[grepl("Fitzpatrick Dorsey" ,x)]<-"Donte Fitzpatrick"
x[x=="Tony Mitch"]<-"Tony Mitchell"
x[x=="Sam Mccracken"]<-"Sam Mccraken"
x[x=="Ravonn Posey"]<-"Pj Posey"
x[grepl("Francis Ramirez", x)]<-"Brandone Francis"
x[grepl("Strong Moore", x)]<-"Darrion Strong"
x[grepl("Nye Redding", x)]<-"Ny Redding"
x[x=="Devante Fitzgerald"|x=="Davante Fitzgerald"]<-"Davonte Fitzgerald"
x[grepl("Hamdy Mohammed", x)]<-"Ahmed Hamdy"
x[x=="Dadrian Allen"]<-"Darian Allen"
x[x=="Reginald Gee"]<-"Reggie Gee"
x[grepl("Cj Williamson", x)]<-"Cj Williamson"
x[x=="Trevon Seymore"]<-"Trey Seymour"
x[x=="Jabarr Singleton"]<-"Jabbar Singleton"
x[grepl("marnier Cunningham", x)]<-"Dmarnier Cunningham"
x[grepl("Bueno Leite", x)]<-"Rico Bueno"
x[grepl("urroughs Cook", x)]<-"Johnathan Cook"
x[grepl("Jere Vu", x)]<-"Jere Vucica"
x[grepl("Cartagena Reyes", x)]<-"Miguel Cartagena"
x[grepl("Walt Lawson", x)]<-"J Walker Lawson"
x[x=="Mcwisdom Badejo"]<-"Mcwisdon Badejo"
x[x=="Chiekh Mbacke Diong"]<-"Cheikh Mbacke Diong"
x[x=="Dantiel Daniels"]<-"Tiel Daniels"
x[x=="Justin Phillipe"]<-"Justin Philippe"
x[x=="Cj Turman"]<-"Cedric Turman"
x[x=="Jarell Lane"]<-"Jarrel Lane"
x[x=="Darryln Johnson"]<-"Darrvin Johnson"
x[x=="Nicola Djogo"]<-"Nikola Djogo"
x[x=="Trevon James"]<-"Trey James"
x[x=="Denzel Mcdaniel"]<-"Denaell Mcdaniel"
x[x=="Shayok Shayok"]<-"Shayok M Shayok"
x[x=="Ngijol Songolo"]<-"Robert Songolo Ngijol"
x[x=="Darius Gardner"]<-"Pee Wee Gardner"
x[x=="Mohammed Fall"]<-"Mohammed Tamsir Fall"
x[x=="Rakim Brown"]<-"Rocky Brown"
x[x=="Michael Harrell"]<-"Michael Harrel"
x[x=="Rashad James"]<-"Rashaad James"
x[x=="Jevon Lyle"]<-"Jr Lyle"
x[x=="Stan Wier"]<-"Stan Weir"
x[x=="Igor Nujic"]<-"Iggy Nujic"
x[x=="Xavier Simpson"]<-"Zavier Simpson"
x[x=="Jason Rich"]<-"Jason Richardson"
x[x=="Kezie Okpala"]<-"Kz Okpala"
x[x=="N Alex Walker"]<-"Nickeil Alex Walker"
x[x=="S Gilgeous Alexander"]<-"Shai Alexander"
x[x=="M Ashton Langford"]<-"Makai Ashton Langford"
x[x=="P Jackson Cartwright"]<-"Parker Jackson Cartwright"
x[x=="Ikey Obiagu"]<-"Ike Obiagu"
x[x=="Marcos Santos Silva"]<-"Marcus Santos Silva"
x[x=="Chris Sodom"]<-"Chris Yannick Sodom"
x[x=="D Cosby Roundtree"]<-"Dhamir Cosby Roundtree"
x[x=="Ty Shon Alexander"]<-"Tyshon Alexander"
x[x=="Tejonathan Lucas"]<-"Tejon Lucas"
x[x=="Johnnie Vasser"]<-"Johnnie Vassar"
x[x=="Deaundre Ballard"]<-"Deaundrae Ballard"
x[x=="Tony Anderson"]<-"Anthony Anderson"
x[x=="Abdulhakim Ado"]<-"Abdul Ado"
x[x=="Chris Darrington"]<-"Chris Darington"
x[x=="Q Weatherspoon"]<-"Quinndary Weatherspoon"
x[x=="D Smith Rivera"]<-"Dvauntes Smith Rivera"
x[x=="D Washington"]<-"Darius Washington"
x[x=="Jamorko Pickett"]<-"Jamarko Pickett"
x[x=="J Williams"]<-"Johnathan Williams"
x[x=="L Morris Walker"]<-"Langston Morris Walker"
x[x=="J Coombs Mcdaniel"]<-"Jamaal Coombs Mcdaniel"
x[x=="M Bryan Amaning"]<-"Matt Bryan Amaning"
x[x=="Harold Baruti"]<-"Bitumba Baruti"
x[x=="S Dorsey Walker"]<-"Sherron Dorsey Walker"
x[x=="Davonte Lacey"]<-"Davonte Lacy"
x[x=="Imara Ready"]<-"Ij Ready"
x[x%in% c("Charles Obannon", "Charles Obannon Jr", "Chuck Obannon", "Chuck Obannon Jr")]<-"Chuck Obannon"
x[x=="Timmel Eggleston"]<-"Melo Eggleston"
x[x=="Anthony Jp Cortesia"]<-"Anthony Cortesia"
x[x=="Leo Criswell"]<-"Leo Lyons"
x[x=="Jonathan Reyes"]<-"Jonathan Reyes"
x[x=="Josh Fortney"]<-"Josh Forney"
x[x=="Malik Price Martin"]<-"Malik Martin"
x[x=="Jay Jay Chandler"]<-"Jj Chandler"
x[x=="Gary E Johnson"]<-"Gary Johnson"
x[x=="Gary E Johnson"]<-"Gary Johnson"
x[grepl("Tugs Bowen", x)]<-"Brian Bowen"
x[x=="Jovontae Milner"]<-"Jovontae Millner"
x[x=="Jagan Mosely"]<-"Jagan Mosley"
x[x=="Jonathan Riek"]<-"Jonathan Reik"
x[x=="Antonio Graves Davis"]<-"Antonio Graves"
x[x=="E Victor Nickerson"]<-"Victor Nickerson"
x[x=="Tory Miller"]<-"Tory Miller Stewart"
x[x=="Jerald Butler"]<-"Jerald Gillens Butler"
x[x=="Jonathan Reyes"|x=="Jonathan Carlos Reyes"]<-"Johncarlos Reyes"
x[x=="Aljami Durham"]<-"Aj Durham"
x[x=="Ibrahim Famouke Doumbia"]<-"Ibrahim Doumbia"
x[x=="Rashond Salnave"]<-"Ray Salnave"
x[x=="Quindarius Brown"]<-"Tookie Brown"
x[x=="Jonathan Mayhanne"]<-"Jonathan Mayhane"
x[x=="St Pierre"]<-"Joe St Pierre"
x[x=="Ronshad Shabazz"]<-"Ronshad Allen Shabazz"
x[x=="Tulio Henrique"]<-"Tulio Da Silva"
x[x=="Al Eichelberger"]<-"Algevon Eichelberger"
x[x=="Donovan Love"]<-"Donavan Theme Love"
x[x=="Dante Hayes Williams"|x=="Dante Hales Williams"]<-"Dante Williams"
x[x=="Jean Marc Christ Koumadje"]<-"Jean Marc Koumadje"
x[x=="Juby Johnson"]<-"Julius Johnson"
x[x=="Ky Bowman"]<-"Kyran Bowman"
x[x=="Norbertas Giga"]<-"Norbertas Gigas"
x[x=="Xavier Blount Johnson"]<-"Xavier Blount"
x[x=="Colin Goss"]<-"Collin Goss"
x[x=="Maxwell Hoetzel"]<-"Maxwell Montana"
x[x=="Therren Szmidt"]<-"Therren Shelton Szmidt"
x[x=="Guy Landry"]<-"Guy Edi"
x[x=="Cheikh Mbodji"]<-"Cheikh Mbodj"
x[x=="Marquis Godwin"]<-"Marquise Godwin"
x[x=="Mario Haskett"]<-"Rio Haskett"
x[x=="Nate Butler"]<-"Nate Butler Lind"
x[x=="Stacey Wilson"]<-"Stacy Wilson"
x[x=="Immanuel Quickly"]<-"Immanuel Quickley"
x[x=="Demario Hines"]<-"Mario Hines"
x[x=="Duvuaghn Maxwell"]<-"Duvaughn Maxwell"
x[x=="Shareif Adumu"]<-"Shareif Adamu"
x[x=="Trantell Knight"]<-"Tweety Knight"
x[x=="Ashauhn Dixon Tatum"]<-"Asauhn Dixon Tatum"
x[x=="Tymel Murphy"]<-"Tymell Murphy"
x[x=="Dre Connor"]<-"Dre Conner"
x[x=="Cheikh Fall"]<-"Ali Fall"
x[x=="Ken Cherry"]<-"Ken Chery"
x[x=="Joe Ucehbo"]<-"Joe Uchebo"
x[x=="Remi Dibo"]<-"Remi N E Dibo"
x[x=="Dre Mathieu"]<-"Deandre Mathieu"
x[x=="Trevuaghn White"]<-"Corey Allen"
x[x=="Cory Allen"]<-"Travaughn White"
x[x=="Isahiah Williams"]<-"Isaiah Williams"
x[x=="Ocatvious Green"]<-"Octavius Green"
x[x=="Dejuan Newton"]<-"Desjuan Newton"
x[x=="Teigbe Bamba"]<-"Tiegbe Bamba"
x[x=="Aaron Adoye"]<-"Aaron Adeoye"
x[x=="Trashon Burrell"]<-"Trahson Burrell"
x[x=="Dinjyl Walker"]<-"Dinjiyl Walker"
x[x=="Correante Deberry"]<-"Coreontae Deberry"
x[x=="Devaughn Purcell"]<-"Devaughn Akoon Purcell"
x[x=="Ivan Uceda"]<-"Ivan Cruz"
x[x=="Devnota Pollard"]<-"Devonta Pollard"
x[x=="Joe Thomassen"]<-"Joe Thomasson"
x[x=="Bush Wamukota"]<-"Tom Wamukota"
x[x=="Devuangtah Williams"]<-"Devaugntah Williams"
x[x=="Fred Dure"]<-"Frederic Dure"
x[x=="Betrand Nkali"]<-"Bertrand Nkali"
x[x=="Rayanthony Sanders"]<-"Ray Sanders"
x[x=="Jusitn Roberson"]<-"Justin Roberson"
x[x=="Billydee Williams"]<-"Billy Dee Williams"
x[x=="Ty Criswell"]<-"Tyron Criswell"
x[x=="Joe Acuil"]<-"Jo Acuil"
x[x=="Fredrick Edmond"]<-"Frederick Edmond"
x[x=="Ahmed Mohammed"]<-"Ahmed Hamdy"
x[x=="Buay Tauch"]<-"Buay Tuach"
x[x=="Willie Connors"]<-"Willie Conner"
x[x=="Jarell Marshall"]<-"Jarrel Marshall"
x[grepl("Ethan", x)& grepl("Telfair", x)]<-"Ethan Telfair"
x[x=="Semajae Haynes Jones"]<-"Samajae Haynes Jones"
x[x=="Josh Webstera"]<-"Josh Webster"
x[x=="Dejuan Morrero"]<-"Dejuan Marrero"
x[x=="Cam Reedus"]<-"Camron Reedus"
x[x=="Zachary Cuthbertson"]<-"Zac Cuthbertson"
x[x=="Leroy Buchanan"]<-"Shaquille Buchanan"
x[x=="Benjamin Nakwaasaha"]<-"Benjamin Nakwaasah"
x[x=="Kj Scott"]<-"Kevin Scott"
x[x=="Jamar Sandifer"]<-"Jamar Sandfer"
x[x=="Temetrius Morant"]<-"Ja Morant"
x[x=="Nate Nahirny"]<-"Nate Nahimy"
x[x=="Ibrahima Sankary"]<-"Ibrahima Sankare"
x[x=="Cyzanne Carson"]<-"Cezanne Carson"
x[x=="Tray Bryant"]<-"Trae Bryant"
x[x=="Jordan Varnado"]<-"Jordon Varnado"
x[x=="Aj Mosby"]<-"Anthony Mosby"
x[x=="Isaiah Blackmon"]<-"Isiah Blackmon"
x[x=="Temidayo Yussuf"]<-"Temidayo Yussef"
x[x=="Francis Alonso"]<-"Francisco Alonso"
x[x=="Eli Pemberton"]<-"Elijah Pemberton"
x[x=="Eli Cain"]<-"Elijah Cain"
x[x=="Ryan Swan"]<-"Ryan Swan Ford"
x[x=="Maurice Greenwood"]<-"Moses Greenwood"
x[x=="Jakub Niziol"]<-"Kuba Niziol"
x[x=="Brandonn Kamga"]<-"Brandon Kamga"
x[x=="Artur Labinowicz"]<-"Art Labinowicz"
x[x=="Nyaires Redding"]<-"Ny Redding"
x[x=="Eli Scott"]<-"Elizjah Scott"
x[x=="Sabastian Townes"]<-"Sebastian Townes"
x[x=="Frederick Scott"]<-"Fred Scott"
x[x=="Deederick Petty"]<-"Deedrick Petty"
x[x=="Alex Dargenten"]<-"Alexis Dargentin"
x[x=="Anthony Gatson"]<-"Anthony Gaston"
x[x=="Georgie Pacheco Ortiz"]<-"Jorge Pacheco Ortiz"
x[x=="Khari Jabriel Allen"]<-"Jabriel Allen"
x[x=="Arnaldo Toro"]<-"Arnaldo Toro Barea"
x[x=="Von Julien"]<-"Charvon Julien"
x[x=="Wajid Aminu"]<-"Al Wajid Aminu"
x[x=="Rene Castro"|x=="Rene Cannedy"| grepl("Rene Castro", x)]<-"Rene Castro Caneddy"
x[x=="Leantwaun Luckett"]<-"Leantwan Luckett"
x[x=="Aj Astroph"]<-"Aj Astroth"
x[x=="Will Green"]<-"Willie Green"
x[x=="Roy Marble"|x=="Roy Devyn Marble"]<-"Devyn Marble"
x[x=="Donavan Theme Love"]<-"Donovan Theme Love"
#names like DaiJon or Dai Jon that accidentally got changed to jonathan
x<-gsub("jonathan |john |johnathan ", "jon ", x)
x<-gsub(" Jonathan", " Jon", x)
x[grepl("Branislav Terz", x)]<-"Branislav Terzic"
x[grepl("Saint Gelais", x)]<-"Allan Saint Gelais"
x[grepl("Muepo Kelly", x)]<-"Dj Muepo Kelly"
x[grepl("Obiagu", x) & grepl("Ike", x)]<-"Ike Obiagu"
x<-gsub("Vils", "Vila", x)
x<-gsub("Enique", "Enrique", x)
x
}
simpleCap <- function(x) {
x<-tolower(x)
s <- strsplit(x, " ")[[1]]
paste(toupper(substring(s, 1,1)), substring(s, 2),
sep="", collapse=" ")
}
moving<-function(x, length, operation="mean") {
#x<-c(2, 4, 1,2,4,1,2,4 ,4,4, 10, 1, NA, 1, 1, 1, 2 , NA,3, NA, 2);length<-10
#x<-c(NA, NA)
#if(operation%in% c())
x2<-x
if(operation%in% c("harmonic", "geometric")) {
x[x<=0]<-NA
}
if(operation=="mean" & length(x)>=1) {
y<-rep(NA, length(x))
if(is.na(x[1])) {
y[1]<-sum(x[!is.na(x)][1:min(length, length(x[!is.na(x)]))])/
length(x[!is.na(x)][1:min(length, length(x[!is.na(x)]))])
}
if(length(x[!is.na(x)])>length) {
#rolling mean of previous values
y[!is.na(x)]<-append(rollmean(x[!is.na(x)], length,na.pad=TRUE, align="left" )[-1], NA)
#fill in first few games with cumulative moving ave
y[is.na(y) & !is.na(x)]<-rev(cumsum(rev(x[is.na(y) & !is.na(x)]))-rev(x[is.na(y) & !is.na(x)]))/
rev(seq_along(x[is.na(y) & !is.na(x)])-1)
#fill in missing games with previous game
y<-na.locf(y, fromLast=FALSE,na.rm=FALSE)
} else{
#fill in first few games with cumulative moving ave
y[is.na(y) & !is.na(x)]<-rev(cumsum(rev(x[is.na(y) & !is.na(x)]))-rev(x[is.na(y) & !is.na(x)]))/
rev(seq_along(x[is.na(y) & !is.na(x)])-1)
#fill in missing games with previous game
y<-na.locf(y, fromLast=FALSE,na.rm=FALSE)
}
} else if (operation=="median" & length(x)>=1) {
y<-rep(NA, length(x))
if(is.na(x[1])) {
y[1]<-median(x[!is.na(x)][1:min(length, length(x[!is.na(x)]))])
}
if(length(x[!is.na(x)])>length) {
#rolling median of previous values
y[!is.na(x)]<-append(rollmedian(x[!is.na(x)], length,na.pad=TRUE, align="left" )[-1], NA)
#fill in first few games with cumulative moving ave
y[is.na(y) & !is.na(x)]<-rev(cumsum(rev(x[is.na(y) & !is.na(x)]))-rev(x[is.na(y) & !is.na(x)]))/
rev(seq_along(x[is.na(y) & !is.na(x)])-1)
#fill in missing games with previous game
y<-na.locf(y, fromLast=FALSE,na.rm=FALSE)
} else{
#fill in first few games with cumulative moving ave
y[is.na(y) & !is.na(x)]<-rev(cumsum(rev(x[is.na(y) & !is.na(x)]))-rev(x[is.na(y) & !is.na(x)]))/
rev(seq_along(x[is.na(y) & !is.na(x)])-1)
#fill in missing games with previous game
y<-na.locf(y, fromLast=FALSE,na.rm=FALSE)
}
} else if (operation=="max" & length(x)>=1) {
#x<-c(2, 4, 1,2,4,1,2,4 ,4,4, 10, 1, NA, 1, 1, 1, 2 , NA,3, NA, 2);length<-4
y<-rep(NA, length(x))
if(is.na(x[1])) {
y[1]<-max(x[!is.na(x)][1:min(length, length(x[!is.na(x)]))])
}
if(length(x[!is.na(x)])>length) {
#rolling median of previous values
y[!is.na(x)]<-append(rollmax(x[!is.na(x)], length,na.pad=TRUE, align="left" )[-1], NA)
#fill in first few games with cumulative moving ave
y[is.na(y) & !is.na(x)][-length( y[is.na(y) & !is.na(x)])]<-
rev(cummax(rev(x[is.na(y) & !is.na(x)]))[-length(cummax(rev(x[is.na(y) & !is.na(x)])))])
#fill in missing games with previous game
y<-na.locf(y, fromLast=FALSE,na.rm=FALSE)
} else{
#fill in first few games with cumulative moving ave
y[is.na(y) & !is.na(x)][-length( y[is.na(y) & !is.na(x)])]<-
rev(cummax(rev(x[is.na(y) & !is.na(x)]))[-length(cummax(rev(x[is.na(y) & !is.na(x)])))])
#fill in missing games with previous game
y<-na.locf(y, fromLast=FALSE,na.rm=FALSE)
}
} else if (operation=="min" & length(x)>=1) {
x<-(-x)
y<-rep(NA, length(x))
if(is.na(x[1])) {
y[1]<-max(x[!is.na(x)][1:min(length, length(x[!is.na(x)]))])
}
if(length(x[!is.na(x)])>length) {
#rolling median of previous values
y[!is.na(x)]<-append(rollmax(x[!is.na(x)], length,na.pad=TRUE, align="left" )[-1], NA)
#fill in first few games with cumulative moving ave
y[is.na(y) & !is.na(x)][-length( y[is.na(y) & !is.na(x)])]<-
rev(cummax(rev(x[is.na(y) & !is.na(x)]))[-length(cummax(rev(x[is.na(y) & !is.na(x)])))])
#fill in missing games with previous game
y<-na.locf(y, fromLast=FALSE,na.rm=FALSE)
} else{
#fill in first few games with cumulative moving ave
y[is.na(y) & !is.na(x)][-length( y[is.na(y) & !is.na(x)])]<-
rev(cummax(rev(x[is.na(y) & !is.na(x)]))[-length(cummax(rev(x[is.na(y) & !is.na(x)])))])
#fill in missing games with previous game
y<-na.locf(y, fromLast=FALSE,na.rm=FALSE)
}
y<-(-y)
} else if (operation =="sum" & length(x)>=1) {
y<-rep(NA, length(x))
if(is.na(x[1])) {
y[1]<-sum(x[!is.na(x)][1:min(length, length(x[!is.na(x)]))])
}
if(length(x[!is.na(x)])>length) {
#rolling sum of previous values
y[!is.na(x)]<-append(rollsum(x[!is.na(x)], length,na.pad=TRUE, align="left" )[-1], NA)
#fill in first few games with cumulative moving sum
y[is.na(y) & !is.na(x)]<-rev(cumsum(rev(x[is.na(y) & !is.na(x)]))-rev(x[is.na(y) & !is.na(x)]))
#fill in missing games with previous game
y<-na.locf(y, fromLast=FALSE,na.rm=FALSE)
#fill in first game with next game if NA
y<-na.locf(y, fromLast=TRUE,na.rm=FALSE)