Advanced basketball statistics is an R package that allows you to perform different statistics calculations that are used in the world of basketball. In the package we can perform different calculations for the following types of statistics:

- Calculations on a data set representing individual statistics.
- Calculations on a data set representing lineup statistics.
- Calculations on a data set representing play statistics.
- Calculations on a data set representing team statistics.

To create our data set we can do it in two different ways:

After deciding how to create our data set we must know what analysis we want to perform, since depending on this we will need different types of data sets:

- We can use the functions that allow the transformation of a simple data set, that is, without the calculations performed by the data_adjustment() functions. The functions that the transformation allows are the following:
- individuals_data_adjustment. Function that allows transformation of individual stats and defensive stats.
- lineups_data_adjustment. Function that allows the transformation of lineups.
- play_data_adjustment. Function that allows the transformation of plays.
- team_stats. Function that allows you to perform team statistics.

- We can use Data frames with the format corresponding to the data_adjustment() functions.

Once the two ways of creating the data have been commented, the examples of the data sets for subsequent use are shown:

If we want to perform the analysis of individual statistics, we must have the following data sets:

- Data set that represents individual statistics.
Data set created the individuals_data_adjustment function:

`individual_stats <- data.frame("Name" = c("James","Team"), "G" = c(67,0), "GS" = c(62,0),"MP" = c(2316,1), "FG" = c(643,0), "FGA" = c(1303,0), "3P " = c(148,0),"3PA" = c(425,0),"2P" = c(495,0), "2PA" = c(878,0), "FT" = c(264,0),"FTA" = c(381,0),"ORB" = c(66,0), "DRB" = c(459,0), "AST" = c(684,0),"STL" = c(78,0), "BLK" = c(36,0),"TOV" = c(261,0), "PF" = c(118,0),"PTS" = c(1698,0), "+/-" = c(0,0)) individual_stats <- individuals_data_adjustment(individual_stats) individual_stats #> Name G GS MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT% ORB #> 1 James 67 62 2316 643 1303 0.493 148 425 0.348 495 878 0.564 264 381 0.693 66 #> 2 Team 0 0 1 0 0 0.000 0 0 0.000 0 0 0.000 0 0 0.000 0 #> DRB TRB AST STL BLK TOV PF PTS +/- #> 1 459 525 684 78 36 261 118 1698 0 #> 2 0 0 0 0 0 0 0 0 0`

Data set created with the same structure as the one generated by the individuals_data_adjustment function

`individual <- data.frame("name" = c("LeBron James","Team"),"G" = c(67,0), "GS" = c(62,0),"MP" = c(2316,0),"FG" = c(643,0), "FGA" = c(1303,0), "Percentage FG" = c(0.493,0),"3P" = c(148,0),"3PA" = c(425,0), "Percentage 3P" = c(0.348,0),"2P" = c(495,0),"2PA" = c(878,0), "Percentage 2P" = c(0.564,0),"FT" = c(264,0),"FTA FG" = c(381,0), "Percentage FT" = c(0.693,0), "ORB" = c(66,0),"DRB" = c(459,0), "TRB" = c(525,0),"AST" = c(684,0),"STL" = c(78,0),"BLK" = c(36,0), "TOV" = c(261,0), "PF" = c(118,0),"PTS" = c(1698,0),"+/-" = c(0,0)) individual #> name G GS MP FG FGA Percentage.FG X3P X3PA Percentage.3P X2P #> 1 LeBron James 67 62 2316 643 1303 0.493 148 425 0.348 495 #> 2 Team 0 0 0 0 0 0.000 0 0 0.000 0 #> X2PA Percentage.2P FT FTA.FG Percentage.FT ORB DRB TRB AST STL BLK TOV PF #> 1 878 0.564 264 381 0.693 66 459 525 684 78 36 261 118 #> 2 0 0.000 0 0 0.000 0 0 0 0 0 0 0 0 #> PTS X... #> 1 1698 0 #> 2 0 0`

- Data set representing individual defensive statistics.
- Data set created with the individuals_data_adjustment function:

`defensive_stats <- data.frame("Name" = c("Witherspoon ","Team"), "MP" = c(14,200),"DREB" = c(1,0),"FM" = c(4,0), "BLK" = c(0,0), "FTO" = c(0,0),"STL" = c(1,1), "FFTA" = c(0,0), "DFGM" = c(1,0), "DFTM" = c(0,0)) defensive_stats <- individuals_data_adjustment(defensive_stats) defensive_stats #> Name MP DRB FM BLK TOTAL FM FTO STL TOTAL FTO FFTA DFGM DFTM #> 1 Witherspoon 14 1 4 0 4 0 1 1 0 1 0 #> 2 Team 200 0 0 0 0 0 1 1 0 0 0`

- Data set created with the same structure as the one generated by the individuals_data_adjustment function

`defensive <- data.frame("Name" = c("Witherspoon ","Team"), "MP" = c(14,200),"DREB" = c(1,0), "FM" = c(4,0), "BLK" = c(0,0),"TOTAL FM" = c(4,0),"FTO" = c(0,0), "STL" = c(1,1), "TOTAL FTO " = c(1,0), "FFTA" = c(0,0), "DFGM" = c(1,0), "DFTM" = c(0,0)) defensive #> Name MP DREB FM BLK TOTAL.FM FTO STL TOTAL.FTO. FFTA DFGM DFTM #> 1 Witherspoon 14 1 4 0 4 0 1 1 0 1 0 #> 2 Team 200 0 0 0 0 0 1 0 0 0 0`

- Data set that represents team statistics.
- Data set created with the team_stats function:

`tm_stats <- team_stats(individual_stats) tm_stats #> G MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT% ORB DRB TRB #> 1 0 2317 643 1303 0.493 148 425 0.348 495 878 0.564 264 381 0.693 66 459 525 #> AST STL BLK TOV PF PTS +/- #> 1 684 78 36 261 118 1698 0`

- Data set created with the same structure as the one generated by the team_stats function

`indi_team_stats <- data.frame("G" = c(71), "MP" = c(17090), "FG" = c(3006), "FGA" = c(6269),"Percentage FG" = c(0.48), "3P" = c(782),"3PA" = c(2242), "Percentage 3P" = c(0.349), "2P" = c(2224), "2PA" = c(4027), "Percentage 2P" = c(0.552), "FT" = c(1260),"FTA FG" = c(1728),"Percentage FT" = c(0.729), "ORB" = c(757),"DRB" = c(2490),"TRB" = c(3247),"AST" = c(1803), "STL" = c(612), "BLK" = c(468),"TOV" = c(1077),"PF" = c(1471), "PTS" = c(8054), "+/-" = c(0)) indi_team_stats #> G MP FG FGA Percentage.FG X3P X3PA Percentage.3P X2P X2PA #> 1 71 17090 3006 6269 0.48 782 2242 0.349 2224 4027 #> Percentage.2P FT FTA.FG Percentage.FT ORB DRB TRB AST STL BLK TOV PF #> 1 0.552 1260 1728 0.729 757 2490 3247 1803 612 468 1077 1471 #> PTS X... #> 1 8054 0`

- Data set that represents the statistics of the rival team.
- Data set created with the same structure as the one generated by the team_stats function

`indi_rival_stats <- data.frame("G" = c(71), "MP" = c(17090), "FG" = c(2773), "FGA" = c(6187),"Percentage FG" = c(0.448), "3P" = c(827),"3PA" = c(2373),"Percentage 3P" = c(0.349), "2P" = c(1946), "2PA" = c(3814),"Percentage 2P" = c(0.510), "FT" = c(1270),"FTA FG" = c(1626),"Percentage FT" = c(0.781), "ORB" = c(668), "DRB" = c(2333),"TRB" = c(3001), "AST" = c(1662), "STL" = c(585),"BLK" = c(263),"TOV" = c(1130),"PF" = c(1544), "PTS" = c(7643), "+/-" = c(0)) indi_rival_stats #> G MP FG FGA Percentage.FG X3P X3PA Percentage.3P X2P X2PA #> 1 71 17090 2773 6187 0.448 827 2373 0.349 1946 3814 #> Percentage.2P FT FTA.FG Percentage.FT ORB DRB TRB AST STL BLK TOV PF #> 1 0.51 1270 1626 0.781 668 2333 3001 1662 585 263 1130 1544 #> PTS X... #> 1 7643 0`

If we want to perform the analysis of lineup statistics, we must have the following data sets:

Data set that represents basic lineup statistics.

- Data set created with the lineups_data_adjustment function

`linp_basic <- data.frame("PG"= c("James","Rondo"),"SG" = c("Green","Caruso"), "SF" = c("Caldwell","Kuzma"), "PF" = c("Davis","Davis"), "C" = c("Howard ","Howard"),"MP" = c(7,1), "FG " = c(4,0), "FGA" = c(7,0), "X3P" = c(0,0),"X3PA" = c(2,0),"X2P" = c(4,0), "X2PA" = c(5,0), "FT" = c(1,0), "FTA" = c(3,0),"ORB" = c(2,0), "DRB" = c(5,0), "AST " = c(2,0), "STL " = c(1,0), "BLK " = c(0,0), "TOV " = c(7,2), "PF" = c(1,0), "PLUS" = c(9,0),"MINUS" = c(17,3)) linp_basic <- lineups_data_adjustment(linp_basic) linp_basic #> PG SG SF PF C MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT #> 1 Rondo Caruso Kuzma Davis Howard 1 0 0 0.000 0 0 0 0 0 0.0 0 #> 2 James Green Caldwell Davis Howard 7 4 7 0.571 0 2 0 4 5 0.8 1 #> FTA FT% ORB DRB TRB AST STL BLK TOV PF + - +/- #> 1 0 0.000 0 0 0 0 0 0 2 0 0 3 -3 #> 2 3 0.333 2 5 7 2 1 0 7 1 9 17 -8`

- Data set created with the same structure as the one generated by the lineups_data_adjustment function

`lineup_basic <- data.frame("PG" = c("James","Rondo"),"SG" = c("Green","Caruso"), "SF" = c("Caldwell","Kuzma"), "PF" = c("Davis","Davis"), "C" = c("Howard ","Howard"),"MP" = c(7,1), "FG " = c(4,0), "FGA " = c(7,0),"Percentage FG" = c(0.571,0), "X3P " = c(0,0),"X3PA " = c(2,0),"Percentage 3P" = c(0,0), "X2P " = c(4,0), "X2PA " = c(5,0), "Percentage 2P" = c(0.8,0), "FT " = c(1,0), "FTA " = c(3,0), "Percentage FT" = c(0.333,0), "ORB " = c(2,0), "DRB " = c(5,0),"TRB " = c(7,0), "AST " = c(2,0), "STL " = c(1,0), "BLK " = c(0,0),"TOV " = c(7,2), "PF" = c(1,0), "PLUS" = c(9,0),"MINUS" = c(17,3),"P/M" = c(-8,-3)) lineup_basic #> PG SG SF PF C MP FG. FGA. Percentage.FG X3P.. X3PA.. #> 1 James Green Caldwell Davis Howard 7 4 7 0.571 0 2 #> 2 Rondo Caruso Kuzma Davis Howard 1 0 0 0.000 0 0 #> Percentage.3P X2P. X2PA. Percentage.2P FT. FTA. Percentage.FT ORB. DRB. TRB. #> 1 0 4 5 0.8 1 3 0.333 2 5 7 #> 2 0 0 0 0.0 0 0 0.000 0 0 0 #> AST. STL. BLK. TOV. PF.1 PLUS MINUS P.M #> 1 2 1 0 7 1 9 17 -8 #> 2 0 0 0 2 0 0 3 -3`

Data set that represents extended lineup statistics.

- Data set created with the lineups_data_adjustment function

`linp_extended <- data.frame("PG" = c("James","Rondo"),"SG"= c("Green","Caruso"), "SF" = c("Caldwell","Kuzma"), "PF" = c("Davis","Davis"), "C" = c("Howard ","Howard"),"MP" = c(7,1), "FG " = c(6,0), "OppFG " = c(6,0), "FGA " = c(10,0),"OppFGA " = c(9,0), "X3P " = c(2,0),"Opp3P " = c(1,0),"X3PA " = c(4,0), "Opp3PA " = c(3,0),"X2P" = c(4,0),"Opp2P" = c(5,0),"X2PA " = c(6,0), "Opp2PA" = c(8,0) , "FT " = c(0,0),"OppFT " = c(1,0), "FTA " = c(0,0), "OppFTA" = c(1,0),"OppRB" = c(2,0),"OppOppRB" = c(1,0),"DRB" = c(4,0), "OppDRB" = c(1,0),"AST " = c(5,0),"OppAST " = c(4,0),"STL" = c(1,0), "OppSTL" = c(3,0),"BLK" = c(0,0),"OppBLK" = c(1,0),"TOppV" = c(5,2), "OppTOppV" = c(3,2),"PF" = c(1,0),"OppPF" = c(3,0),"PLUS" = c(15,0), "MINUS" = c(14,3)) linp_extended <- lineups_data_adjustment(linp_extended) linp_extended #> PG SG SF PF C MP FG oFG FGA oFGA 3P o3P 3PA o3PA 2P o2P #> 1 Rondo Caruso Kuzma Davis Howard 1 0 0 0 0 0 0 0 0 0 0 #> 2 James Green Caldwell Davis Howard 7 6 6 10 9 2 1 4 3 4 5 #> 2PA o2PA FT oFT FTA oFTA ORB oORB DRB oDRB TRB oTRB AST oAST STL oSTL BLK #> 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 2 6 8 0 1 0 1 2 1 4 1 6 2 5 4 1 3 0 #> oBLK TOV oTOV PF oPF + - +/- #> 1 0 2 2 0 0 0 3 -3 #> 2 1 5 3 1 3 15 14 1`

- Data set created with the same structure as the one generated by the lineups_data_adjustment function

`lineup_extended <- data.frame("PG" = c("James","Rondo"),"SG" = c("Green","Caruso"), "SF" = c("Caldwell","Kuzma"), "PF" = c("Davis","Davis"), "C" = c("Howard ","Howard"),"MP" = c(7,1), "FG " = c(6,0), "OppFG " = c(6,0), "FGA " = c(10,0),"OppFGA " = c(9,0), "X3P " = c(2,0),"Opp3P" = c(1,0),"X3PA" = c(4,0),"Opp3PA" = c(3,0), "X2P" = c(4,0),"Opp2P " = c(5,0), "X2PA " = c(6,0),"Opp2PA " = c(8,0) , "FT " = c(0,0),"OppFT " = c(1,0), "FTA " = c(0,0),"OppFTA " = c(1,0), "OppRB " = c(2,0),"OppOppRB " = c(1,0), "DRB" = c(4,0),"OppDRB" = c(1,0), "TRB" = c(6,0),"OppTRB" = c(2,0), "AST " = c(5,0),"OppAST " = c(4,0), "STL " = c(1,0),"OppSTL " = c(3,0), "BLK " = c(0,0), "OppBLK " = c(1,0), "TOppV " = c(5,2), "OppTOppV " = c(3,2),"PF" = c(1,0),"OppPF" = c(3,0), "PLUS" = c(15,0),"MINUS" = c(14,3),"P/M" = c(1,-3)) lineup_extended #> PG SG SF PF C MP FG. OppFG. FGA. OppFGA. X3P.. Opp3P #> 1 James Green Caldwell Davis Howard 7 6 6 10 9 2 1 #> 2 Rondo Caruso Kuzma Davis Howard 1 0 0 0 0 0 0 #> X3PA Opp3PA X2P Opp2P. X2PA. Opp2PA. FT. OppFT. FTA. OppFTA. OppRB. OppOppRB. #> 1 4 3 4 5 6 8 0 1 0 1 2 1 #> 2 0 0 0 0 0 0 0 0 0 0 0 0 #> DRB OppDRB TRB OppTRB AST. OppAST. STL. OppSTL. BLK. OppBLK. TOppV. OppTOppV. #> 1 4 1 6 2 5 4 1 3 0 1 5 3 #> 2 0 0 0 0 0 0 0 0 0 0 2 2 #> PF.1 OppPF PLUS MINUS P.M #> 1 1 3 15 14 1 #> 2 0 0 0 3 -3`

Data set that represents team statistics.

- Data set created with the team_stats function:

`tm_stats <- team_stats(individual_stats) tm_stats #> G MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT% ORB DRB TRB #> 1 0 2317 643 1303 0.493 148 425 0.348 495 878 0.564 264 381 0.693 66 459 525 #> AST STL BLK TOV PF PTS +/- #> 1 684 78 36 261 118 1698 0`

- Data set created with the same structure as the one generated by the team_stats function

`lineup_team_stats <- data.frame("G" = c(71), "MP" = c(17090), "FG" = c(3006), "FGA" = c(6269),"Percentage FG" = c(0.48), "3P" = c(782),"3PA" = c(2242), "Percentage 3P" = c(0.349), "2P" = c(2224), "2PA" = c(4027), "Percentage 2P" = c(0.552), "FT" = c(1260),"FTA FG" = c(1728), "Percentage FT" = c(0.729), "ORB" = c(757), "DRB" = c(2490),"TRB" = c(3247),"AST" = c(1803), "STL" = c(612), "BLK" = c(468),"TOV" = c(1077),"PF" = c(1471), "PTS" = c(8054), "+/-" = c(0)) lineup_team_stats #> G MP FG FGA Percentage.FG X3P X3PA Percentage.3P X2P X2PA #> 1 71 17090 3006 6269 0.48 782 2242 0.349 2224 4027 #> Percentage.2P FT FTA.FG Percentage.FT ORB DRB TRB AST STL BLK TOV PF #> 1 0.552 1260 1728 0.729 757 2490 3247 1803 612 468 1077 1471 #> PTS X... #> 1 8054 0`

Data set that represents the statistics of the rival team.

`lineup_rival_stats <- data.frame("G" = c(71), "MP" = c(17090), "FG" = c(2773), "FGA" = c(6187),"Percentage FG" = c(0.448), "3P" = c(827),"3PA" = c(2373),"Percentage 3P" = c(0.349), "2P" = c(1946), "2PA" = c(3814),"Percentage 2P" = c(0.510), "FT" = c(1270),"FTA FG" = c(1626), "Percentage FT" = c(0.781), "ORB" = c(668), "DRB" = c(2333),"TRB" = c(3001), "AST" = c(1662), "STL" = c(585),"BLK" = c(263),"TOV" = c(1130),"PF" = c(1544), "PTS" = c(7643), "+/-" = c(0)) lineup_rival_stats #> G MP FG FGA Percentage.FG X3P X3PA Percentage.3P X2P X2PA #> 1 71 17090 2773 6187 0.448 827 2373 0.349 1946 3814 #> Percentage.2P FT FTA.FG Percentage.FT ORB DRB TRB AST STL BLK TOV PF #> 1 0.51 1270 1626 0.781 668 2333 3001 1662 585 263 1130 1544 #> PTS X... #> 1 7643 0`

If we want to perform the analysis of play statistics, we must have the following data sets:

- Data set that represents play statistics.
- Data set created with the play_data_adjustment function

`play_stats <- data.frame("Name" = c("Sabonis ","Team"), "GP" = c(62,71),"PTS" = c(387,0), "FG" = c(155,1), "FGA" = c(281,1),"3P" = c(6,1),"3PA" = c(18,1), "FT" = c(39,1), "FTA" = c(53,1),"ANDONE" = c(12,1), "AST" = c(0,1), "TOV" = c(27,1)) play_stats <- play_data_adjustment(play_stats) play_stats #> Name GP PTS FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT% ANDONE #> 1 Sabonis 62 387 155 281 0.552 6 18 0.333 149 263 0.567 39 53 0.736 12 #> 2 Team 71 0 1 1 1.000 1 1 1.000 0 0 0.000 1 1 1.000 1 #> AST TOV #> 1 0 27 #> 2 1 1`

- Data set created with the same structure as the one generated by the play_data_adjustment function

`play <- data.frame("Name" = c("Sabonis ","Team"), "GP" = c(62,71),"PTS" = c(387,0), "FG" = c(155,1), "FGA" = c(281,1),"3P" = c(6,1),"3PA" = c(18,1), "FT" = c(39,1), "FTA" = c(53,1),"ANDONE" = c(12,1), "AST" = c(0,1), "TOV" = c(27,1)) play #> Name GP PTS FG FGA X3P X3PA FT FTA ANDONE AST TOV #> 1 Sabonis 62 387 155 281 6 18 39 53 12 0 27 #> 2 Team 71 0 1 1 1 1 1 1 1 1 1`

- Data set that represents team statistics.
- Data set created with the team_stats function:

`tm_stats <- team_stats(individual_stats) tm_stats #> G MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT% ORB DRB TRB #> 1 0 2317 643 1303 0.493 148 425 0.348 495 878 0.564 264 381 0.693 66 459 525 #> AST STL BLK TOV PF PTS +/- #> 1 684 78 36 261 118 1698 0`

- Data set created with the same structure as the one generated by the team_stats function

`play_team_stats <- data.frame("G" = c(71), "MP" = c(17090), "FG" = c(3006), "FGA" = c(6269),"Percentage FG" = c(0.48), "3P" = c(782),"3PA" = c(2242), "Percentage 3P" = c(0.349), "2P" = c(2224), "2PA" = c(4027), "Percentage 2P" = c(0.552), "FT" = c(1260),"FTA FG" = c(1728), "Percentage FT" = c(0.729), "ORB" = c(757),"DRB" = c(2490),"TRB" = c(3247),"AST" = c(1803), "STL" = c(612), "BLK" = c(468),"TOV" = c(1077),"PF" = c(1471), "PTS" = c(8054), "+/-" = c(0)) play_team_stats #> G MP FG FGA Percentage.FG X3P X3PA Percentage.3P X2P X2PA #> 1 71 17090 3006 6269 0.48 782 2242 0.349 2224 4027 #> Percentage.2P FT FTA.FG Percentage.FT ORB DRB TRB AST STL BLK TOV PF #> 1 0.552 1260 1728 0.729 757 2490 3247 1803 612 468 1077 1471 #> PTS X... #> 1 8054 0`

- Data set that represents the statistics of the rival team.

`play_rival_stats <- data.frame("G" = c(71), "MP" = c(17090), "FG" = c(2773), "FGA" = c(6187),"Percentage FG" = c(0.448), "3P" = c(827),"3PA" = c(2373),"Percentage 3P" = c(0.349), "2P" = c(1946), "2PA" = c(3814),"Percentage 2P" = c(0.510), "FT" = c(1270),"FTA FG" = c(1626),"Percentage FT" = c(0.781), "ORB" = c(668),"DRB" = c(2333),"TRB" = c(3001),"AST" = c(1662), "STL" = c(585),"BLK" = c(263),"TOV" = c(1130),"PF" = c(1544), "PTS" = c(7643), "+/-" = c(0)) play_rival_stats #> G MP FG FGA Percentage.FG X3P X3PA Percentage.3P X2P X2PA #> 1 71 17090 2773 6187 0.448 827 2373 0.349 1946 3814 #> Percentage.2P FT FTA.FG Percentage.FT ORB DRB TRB AST STL BLK TOV PF #> 1 0.51 1270 1626 0.781 668 2333 3001 1662 585 263 1130 1544 #> PTS X... #> 1 7643 0`

If we want to perform the analysis of team statistics, we must have the following data sets:

Data set that represents the statistics of the team.

- Data set created with the team_stats function:

- Data set created with the same structure as the one generated by the team_stats function

`team_stats <- data.frame("G" = c(71), "MP" = c(17090), "FG" = c(3006), "FGA" = c(6269),"Percentage FG" = c(0.48), "3P" = c(782),"3PA" = c(2242), "Percentage 3P" = c(0.349), "2P" = c(2224), "2PA" = c(4027),"Percentage 2P" = c(0.552), "FT" = c(1260),"FTA FG" = c(1728),"Percentage FT" = c(0.729), "ORB" = c(757),"DRB" = c(2490),"TRB" = c(3247),"AST" = c(1803), "STL" = c(612),"BLK" = c(468),"TOV" = c(1077),"PF" = c(1471), "PTS" = c(8054), "+/-" = c(0)) team_stats #> G MP FG FGA Percentage.FG X3P X3PA Percentage.3P X2P X2PA #> 1 71 17090 3006 6269 0.48 782 2242 0.349 2224 4027 #> Percentage.2P FT FTA.FG Percentage.FT ORB DRB TRB AST STL BLK TOV PF #> 1 0.552 1260 1728 0.729 757 2490 3247 1803 612 468 1077 1471 #> PTS X... #> 1 8054 0`

Data set that represents the statistics of the rival team.

`rival_stats <- data.frame("G" = c(71), "MP" = c(17090), "FG" = c(2773), "FGA" = c(6187),"Percentage FG" = c(0.448), "3P" = c(827),"3PA" = c(2373),"Percentage 3P" = c(0.349), "2P" = c(1946), "2PA" = c(3814),"Percentage 2P" = c(0.510), "FT" = c(1270),"FTA FG" = c(1626),"Percentage FT" = c(0.781), "ORB" = c(668),"DRB" = c(2333),"TRB" = c(3001),"AST" = c(1662), "STL" = c(585),"BLK" = c(263),"TOV" = c(1130),"PF" = c(1544), "PTS" = c(7643), "+/-" = c(0)) rival_stats #> G MP FG FGA Percentage.FG X3P X3PA Percentage.3P X2P X2PA #> 1 71 17090 2773 6187 0.448 827 2373 0.349 1946 3814 #> Percentage.2P FT FTA.FG Percentage.FT ORB DRB TRB AST STL BLK TOV PF #> 1 0.51 1270 1626 0.781 668 2333 3001 1662 585 263 1130 1544 #> PTS X... #> 1 7643 0`

Once the data sets have been created, we must choose which function or functions we want to use. Below are the different functions that the package has:

For individual statistics there are the following functions:

**individuals_advance_stats.**Function that allows advanced statistics calculation.**individuals_defensive_actual_floor_stats.**Function that allows the calculation of the current defensive statistics.**individuals_defensive_estimated_floor_stats.**Function that allows the calculation of the estimated defensive statistics.**individuals_games_adder.**Function that allows the sum of two different individual statistics.**individuals_ofensive_floor_stats.**Function that allows the calculation of offensive statistics.**individuals_stats_per_game.**Function that allows the calculation of statistics per game.**individuals_stats_per_minutes.**Function that allows the calculation of statistics per minutes.**individuals_stats_per_possesion.**Function that allows the calculation of statistics per possessions.

Below is an example of how each function works and what the input parameters should be for these:

For this function we will have to enter individual statistics, team statistics and rival team statistics:

```
advanced_stats <- individuals_advance_stats(individual,indi_team_stats,indi_rival_stats)
advanced_stats
#> Name G GS MP PER eFG% TS% 3PAr FTr ORB% DRB% TRB% AST%
#> 1 LeBron James 67 62 2316 28.68 0.55 0.577 0.326 0.292 3.15 21.45 12.4 49.07
#> STL% BLK% TOV% USG%
#> 1 1.6 1.39 15.07 31.53
```

For this function we will have to enter defensive individual statistics, team statistics and rival team statistics:

```
defensive_actual_stats <- individuals_defensive_actual_floor_stats(defensive,indi_team_stats,indi_rival_stats)
defensive_actual_stats
#> Name MP DStops DScPoss DPoss Stop% TMDPoss% DRtg
#> 1 Witherspoon 14 3.62 1 4.62 0.784 0.002 106.22
#> 2 Team 200 1.00 0 1.00 1.000 0.000 106.32
```

For this function we will have to enter individual statistics, team statistics and rival team statistics:

```
defensive_estimated_stats <- individuals_defensive_estimated_floor_stats(individual,indi_team_stats,indi_rival_stats)
defensive_estimated_stats
#> Name G Stops Stop% DRtg
#> 1 LeBron James 67 7.73 0.532 106.23
```

For this function we will have to enter the two individual statistics previously calculated which we want to add the statistics:

```
games_adder <- individuals_games_adder(individual,individual)
games_adder
#> Name G GS MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT
#> 1 LeBron James 134 124 4632 1286 2606 0.493 296 850 0.348 990 1756 0.564 528
#> 2 Team 0 0 0 0 0 0.000 0 0 0.000 0 0 0.000 0
#> FTA FT% ORB DRB TRB AST STL BLK TOV PF PTS +/-
#> 1 762 0.693 132 918 1050 1368 156 72 522 236 3396 0
#> 2 0 0.000 0 0 0 0 0 0 0 0 0 0
```

For this function we will have to enter individual statistics, team statistics and rival team statistics:

```
ofensive_stats <- individuals_ofensive_floor_stats(individual,indi_team_stats,indi_rival_stats)
ofensive_stats
#> Name G Sc. Poss Poss Floor% ORtg Pts Prod/G
#> 1 LeBron James 67 12.74 24.12 0.528 115.67 27.9
```

For this function we will have to enter individual statistics:

```
per_game_stats <- individuals_stats_per_game(individual)
per_game_stats
#> Name G GS MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT
#> 1 LeBron James 67 62 34.57 9.6 19.45 0.493 2.21 6.34 0.348 7.39 13.1 0.564 3.94
#> FTA FT% ORB DRB TRB AST STL BLK TOV PF PTS +/-
#> 1 5.69 0.693 0.99 6.85 7.84 10.21 1.16 0.54 3.9 1.76 25.34 0
```

For this function we will have to enter the individual statistics and the number of minutes to which we want to project the statistics:

```
per_minutes_stats <- individuals_stats_per_minutes(individual,36)
per_minutes_stats
#> Name G GS MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT
#> 1 LeBron James 67 62 2316 9.99 20.25 0.493 2.3 6.61 0.348 7.69 13.65 0.564 4.1
#> FTA FT% ORB DRB TRB AST STL BLK TOV PF PTS +/-
#> 1 5.92 0.693 1.03 7.13 8.16 10.63 1.21 0.56 4.06 1.83 26.39 0
```

For this function we will have to enter the individual statistics, the team statistics, the rival team statistics, the number of minutes that a single game lasts and the number of possessions to which we want to project the statistics:

```
per_poss_stats <- individuals_stats_per_possesion(individual,indi_team_stats,indi_rival_stats,100,48)
per_poss_stats
#> Name G GS MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P%
#> 1 LeBron James 67 62 2316 13.2 26.75 0.493 3.04 8.73 0.348 10.16 18.03 0.564
#> FT FTA FT% ORB DRB TRB AST STL BLK TOV PF PTS +/-
#> 1 5.42 7.82 0.693 1.36 9.42 10.78 14.04 1.6 0.74 5.36 2.42 34.86 0
```

For individual statistics there are the following functions:

**lineups_advance_stats.**Function that allows advanced statistics calculation.**lineups_backcourt.**Function that allows searching for backcourt players.**lineups_comparator_stats.**Function that allows comparison between the statistics of the lineup and the rival lineup**lineups_games_adder.**Function that allows the sum of two different lineup statistics.**lineups_paint.**Function that allows searching for paint players.**lineups_players.**Function that allows searching for players by position.**lineups_searcher.**Function that allows searching for players within the data frame.**lineups_separator.**Function that allows you to obtain the statistics of the lineups or the rivals against those lineups.**lineups_stats_per_possesion.**Function that allows the calculation of statistics per possessions

Below is an example of how each function works and what the input parameters should be for these:

For this function we will have to enter extended lineup statistics and the number of minutes that a single game lasts:

```
lnp_advanced_stats <- lineups_advance_stats(lineup_extended,48)
lnp_advanced_stats
#> PG SG SF PF C MP TEAM% PACE ORtg DRtg Net Rtg
#> 1 James Green Caldwell Davis Howard 7 1.000 81.959 123.49 119.07 4.42
#> 2 Rondo Caruso Kuzma Davis Howard 1 0.125 0.000 0.00 0.00 0.00
#> 3Par FTr TS% eFG% AST% ORB% DRB% TRB% TOV%
#> 1 0.4 0 0.75 0.7 0.833 0.667 0.8 0.75 0.333
#> 2 0.0 0 0.00 0.0 0.000 0.000 0.0 0.00 1.000
```

For this function we will have to enter basic lineup statistics or extended lineup statistics:

```
lnp_bs_backcourt <- lineups_backcourt(lineup_basic)
lnp_bs_backcourt
#> PG SG SF MP FG FGA Percentage FG 3P 3PA Percentage 3P 2P 2PA
#> 1 James Green Caldwell 7 4 7 0.571 0 2 0 4 5
#> 2 Rondo Caruso Kuzma 1 0 0 0.000 0 0 0 0 0
#> Percentage 2P FT FTA Percentage FT ORB DRB TRB AST STL BLK TOV PF + - +/-
#> 1 0.8 1 3 0.333 2 5 7 2 1 0 7 1 9 17 -8
#> 2 0.0 0 0 0.000 0 0 0 0 0 0 2 0 0 3 -3
```

```
lnp_ex_backcourt <- lineups_backcourt(lineup_extended)
lnp_ex_backcourt
#> PG SG SF MP FG oFG FGA oFGA 3P o3P 3PA o3PA 2P o2P 2PA o2PA FT
#> 1 James Green Caldwell 7 6 6 10 9 2 1 4 3 4 5 6 8 0
#> 2 Rondo Caruso Kuzma 1 0 0 0 0 0 0 0 0 0 0 0 0 0
#> oFT FTA oFTA ORB oORB DRB oDRB TRB oTRB AST oAST STL oSTL BLK oBLK TOV oTOV
#> 1 1 0 1 2 1 4 1 6 2 5 4 1 3 0 1 5 3
#> 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2
#> PF oPF + - +/-
#> 1 1 3 15 14 1
#> 2 0 0 0 3 -3
```

For this function we will have to enter extended lineup statistics:

```
lnp_comparator <- lineups_comparator_stats(lineup_extended,48)
lnp_comparator
#> PG SG SF PF C MP Team% Pace FG FGA FG% 3P 3PA 3P%
#> 1 James Green Caldwell Davis Howard 7 1.000 81.96 0 1 -0.067 1 1 0.167
#> 2 Rondo Caruso Kuzma Davis Howard 1 0.125 0.00 0 0 0.000 0 0 0.000
#> 2P 2PA 2P% eFG% TS% FT FTA FT% +/-
#> 1 -1 -2 0.042 -0.022 0.008 -1 -1 -1 1
#> 2 0 0 0.000 0.000 -Inf 0 0 0 -3
```

For this function we will have to enter basic lineup statistics or extended lineup statistics:

```
lnp_games_adder <- lineups_games_adder(lineup_basic,lineup_basic)
lnp_games_adder
#> PG SG SF PF C MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT
#> 1 Rondo Caruso Kuzma Davis Howard 2 0 0 0.000 0 0 0 0 0 0.0 0
#> 2 James Green Caldwell Davis Howard 14 8 14 0.571 0 4 0 8 10 0.8 2
#> FTA FT% ORB DRB TRB AST STL BLK TOV PF + - +/-
#> 1 0 0.000 0 0 0 0 0 0 4 0 0 6 -6
#> 2 6 0.333 4 10 14 4 2 0 14 2 18 34 -16
```

For this function we will have to enter basic lineup statistics or extended lineup statistics:

```
lnp_bc_paint <- lineups_paint(lineup_basic)
lnp_bc_paint
#> PF C MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT% ORB DRB TRB
#> 1 Davis Howard 1 0 0 0.000 0 0 0 0 0 0.0 0 0 0.000 0 0 0
#> 2 Davis Howard 7 4 7 0.571 0 2 0 4 5 0.8 1 3 0.333 2 5 7
#> AST STL BLK TOV PF + - +/-
#> 1 0 0 0 2 0 0 3 -3
#> 2 2 1 0 7 1 9 17 -8
```

```
lnp_ex_paint <- lineups_paint(lineup_extended)
lnp_ex_paint
#> PF C MP FG oFG FGA oFGA 3P o3P 3PA o3PA 2P o2P 2PA o2PA FT oFT FTA
#> 1 Davis Howard 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 2 Davis Howard 7 6 6 10 9 2 1 4 3 4 5 6 8 0 1 0
#> oFTA ORB oORB DRB oDRB TRB oTRB AST oAST STL oSTL BLK oBLK TOV oTOV PF oPF +
#> 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0 0
#> 2 1 2 1 4 1 6 2 5 4 1 3 0 1 5 3 1 3 15
#> - +/-
#> 1 3 -3
#> 2 14 1
```

For this function we will have to enter basic lineup statistics or extended lineup statistics and the number of position that we want to find:

```
lnp_bc_players <- lineups_players(lineup_basic,5)
lnp_bc_players
#> C MP FG FGA Percentage FG 3P 3PA Percentage 3P 2P 2PA Percentage 2P FT
#> 1 Howard 1 0 0 0.000 0 0 0 0 0 0.0 0
#> 2 Howard 7 4 7 0.571 0 2 0 4 5 0.8 1
#> FTA Percentage FT ORB DRB TRB AST STL BLK TOV PF + - +/-
#> 1 0 0.000 0 0 0 0 0 0 2 0 0 3 -3
#> 2 3 0.333 2 5 7 2 1 0 7 1 9 17 -8
```

```
lnp_ex_players <- lineups_players(lineup_extended,5)
lnp_ex_players
#> C MP FG oFG FGA oFGA 3P o3P 3PA o3PA 2P o2P 2PA o2PA FT oFT FTA oFTA
#> 1 Howard 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 2 Howard 7 6 6 10 9 2 1 4 3 4 5 6 8 0 1 0 1
#> ORB oORB DRB oDRB TRB oTRB AST oAST STL oSTL BLK oBLK TOV oTOV PF oPF + -
#> 1 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0 0 3
#> 2 2 1 4 1 6 2 5 4 1 3 0 1 5 3 1 3 15 14
#> +/-
#> 1 -3
#> 2 1
```

For this function we will have to enter basic lineup statistics or extended lineup statistics, the name of the players that we want to find and the number of players that we want to find:

```
lnp_bc_searcher <- lineups_searcher(lineup_basic,1,"James","","","")
lnp_bc_searcher
#> PG SG SF PF C MP FG. FGA. Percentage.FG X3P.. X3PA..
#> 1 James Green Caldwell Davis Howard 7 4 7 0.571 0 2
#> Percentage.3P X2P. X2PA. Percentage.2P FT. FTA. Percentage.FT ORB. DRB. TRB.
#> 1 0 4 5 0.8 1 3 0.333 2 5 7
#> AST. STL. BLK. TOV. PF.1 PLUS MINUS P.M
#> 1 2 1 0 7 1 9 17 -8
```

```
lnp_ex_searcher <- lineups_searcher(lineup_extended,1,"James","","","")
lnp_ex_searcher
#> PG SG SF PF C MP FG. OppFG. FGA. OppFGA. X3P.. Opp3P
#> 1 James Green Caldwell Davis Howard 7 6 6 10 9 2 1
#> X3PA Opp3PA X2P Opp2P. X2PA. Opp2PA. FT. OppFT. FTA. OppFTA. OppRB. OppOppRB.
#> 1 4 3 4 5 6 8 0 1 0 1 2 1
#> DRB OppDRB TRB OppTRB AST. OppAST. STL. OppSTL. BLK. OppBLK. TOppV. OppTOppV.
#> 1 4 1 6 2 5 4 1 3 0 1 5 3
#> PF.1 OppPF PLUS MINUS P.M
#> 1 1 3 15 14 1
```

For this function we will have to enter extended lineup statistics and the indicator of what type of separation we want to make:

```
lnp_ex_sep_one <- lineups_separator(lineup_extended,1)
lnp_ex_sep_one
#> PG SG SF PF C MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT
#> 1 James Green Caldwell Davis Howard 7 6 10 0.6 2 4 0.5 4 6 0.667 0
#> 2 Rondo Caruso Kuzma Davis Howard 1 0 0 0.0 0 0 0.0 0 0 0.000 0
#> FTA FT% ORB DRB TRB AST STL BLK TOV PF + - +/-
#> 1 0 0 2 4 6 5 1 0 5 1 15 14 1
#> 2 0 0 0 0 0 0 0 0 2 0 0 3 -3
```

```
lnp_ex_sep_two <- lineups_separator(lineup_extended,2)
lnp_ex_sep_two
#> PG SG SF PF C MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P%
#> 1 James Green Caldwell Davis Howard 7 6 9 0.667 1 3 0.333 5 8 0.625
#> 2 Rondo Caruso Kuzma Davis Howard 1 0 0 0.000 0 0 0.000 0 0 0.000
#> FT FTA FT% ORB DRB TRB AST STL BLK TOV PF + - +/-
#> 1 1 1 1 1 1 2 4 3 1 3 3 15 14 1
#> 2 0 0 0 0 0 0 0 0 0 2 0 0 3 -3
```

For this function we will have to enter basic lineup statistics, team statistics, rival team statistics, the number of minutes that a single game lasts and the number of possessions to which we want to project the statistics:

```
lnp_per_poss_stats <- lineups_stats_per_possesion(lineup_basic,lineup_team_stats,lineup_rival_stats,100,48)
lnp_per_poss_stats
#> PG SG SF PF C MP FG FGA FG% 3P 3PA 3P% 2P
#> 1 James Green Caldwell Davis Howard 7 27.17 47.55 0.571 0 13.59 0 27.17
#> 2 Rondo Caruso Kuzma Davis Howard 1 0.00 0.00 0.000 0 0.00 0 0.00
#> 2PA 2P% FT FTA FT% ORB DRB TRB AST STL BLK TOV PF +
#> 1 33.96 0.8 6.79 20.38 0.333 13.59 33.96 47.55 13.59 6.79 0 47.55 6.79 61.14
#> 2 0.00 0.0 0.00 0.00 0.000 0.00 0.00 0.00 0.00 0.00 0 95.10 0.00 0.00
#> - +/-
#> 1 115.48 -54.34
#> 2 142.65 -142.65
```

For individual statistics there are the following functions:

**play_advance_stats.**Function that allows advanced statistics calculation.**play_games_adder.**Function that allows the sum of two different play statistics.**play_stats_per_game.**Function that allows the calculation of statistics per game.**play_stats_per_possesion.**Function that allows the calculation of statistics per possessions.**play_team_stats.**Function that allows to carry out the statistics of the team.

Below is an example of how each function works and what the input parameters should be for these:

For this function we will have to enter play statistics:

```
play_adv_stats <- play_advance_stats(play_stats)
play_adv_stats
#> Name G Poss Freq PPP PTS FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% eFG%
#> 1 Sabonis 62 329 1 1.18 387 155 281 0.552 6 18 0.333 149 263 0.567 0.562
#> FT% AST% TOV% And One% Score%
#> 1 0.161 0 0.082 0.036 0.519
```

For this function we will have to enter play statistics:

```
pl_game_adder <- play_games_adder(play_stats,play_stats)
pl_game_adder
#> Name GP PTS FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT% ANDONE
#> 1 Sabonis 124 774 310 562 0.552 12 36 0.333 298 526 0.567 78 106 0.736 24
#> 2 Team 142 0 2 2 1.000 2 2 1.000 0 0 0.000 2 2 1.000 2
#> AST TOV
#> 1 0 54
#> 2 2 2
```

For this function we will have to enter play statistics:

```
play_per_game_stat <- play_stats_per_game(play_stats)
play_per_game_stat
#> Name GP PTS FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT%
#> 1 Sabonis 62 6.24 2.5 4.53 0.552 0.1 0.29 0.333 2.4 4.24 0.567 0.63 0.85 0.736
#> And One AST TOV
#> 1 0.19 0 0.44
```

For this function we will have to enter the play statistics, the team statistics, the rival team statistics, the number of minutes that a single game lasts and the number of possessions to which we want to project the statistics:

```
play_per_poss_stats <- play_stats_per_possesion(play_stats,play_team_stats,play_rival_stats,100,48)
play_per_poss_stats
#> Name GP PTS FG FGA FG% 3P 3PA 3P% 2P
#> 1 Sabonis 62 33336.42 13351.80 24205.51 0.552 516.84 1550.53 0.333 12834.95
#> 2 Team 71 0.00 47.55 47.55 1.000 47.55 47.55 1.000 0.00
#> 2PA 2P% FT FTA FT% And One AST TOV
#> 1 22654.98 0.567 3359.48 4565.45 0.736 1033.69 0.00 2325.80
#> 2 0.00 0.000 47.55 47.55 1.000 47.55 47.55 47.55
```

For this function we will have to enter play statistics:

```
play_team_stats <- play_team_stats(play_stats)
play_team_stats
#> GP PTS FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT% And One AST TOV
#> 1 71 387 156 282 0.553 7 19 0.368 149 263 0.567 40 54 0.741 13 1 28
```

For individual statistics there are the following functions:

**team_advanced_stats.**Function that allows advanced statistics calculation.**team_stats_per_game.**Function that allows the calculation of statistics per game.**team_stats_per_minutes.**Function that allows the calculation of statistics per minutes.**team_stats_per_possesion.**Function that allows the calculation of statistics per possessions.

Below is an example of how each function works and what the input parameters should be for these:

For this function we will have to enter the team statistics and the rival team statistics:

```
team_adv_stats <- team_advanced_stats(team_stats,rival_stats,48)
team_adv_stats
#> G MP ORtg DRtg NetRtg Pace 3PAr FTr TS% eFG% AST% AST/TO
#> 1 71 17090 112.14 106.23 5.91 100.95 0.358 0.276 0.573 0.542 0.6 1.67
#> ASTRATIO% ORB% TOV% FT/FGA Opp eFG% Opp TOV% DRB% Opp FTr
#> 1 25.1 0.245 0.133 0.201 0.515 0.141 0.788 0.205
```

For this function we will have to enter the team statistics:

```
team_per_game_stat <- team_stats_per_game(team_stats)
team_per_game_stat
#> G MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA
#> 1 71 17090 42.34 88.3 0.48 11.01 31.58 0.349 31.32 56.72 0.552 17.75 24.34
#> FT% ORB DRB TRB AST STL BLK TOV PF PTS +/-
#> 1 0.729 10.66 35.07 45.73 25.39 8.62 6.59 15.17 20.72 113.44 0
```

For this function we will have to enter the team statistics and the number of minutes to which we want to project the statistics:

```
team_per_minutes_stat <- team_stats_per_minutes(team_stats,36)
team_per_minutes_stat
#> G MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA FT%
#> 1 71 17090 31.66 66.03 0.48 8.24 23.61 0.349 23.42 42.41 0.552 13.27 18.2 0.729
#> ORB DRB TRB AST STL BLK TOV PF PTS +/-
#> 1 7.97 26.23 34.2 18.99 6.45 4.93 11.34 15.49 84.83 0
```

For this function we will have to enter the team statistics, the rival team statistics and the number of possessions to which we want to project the statistics::

```
team_per_poss_stat <- team_stats_per_possesion(team_stats,rival_stats,100)
team_per_poss_stat
#> G MP FG FGA FG% 3P 3PA 3P% 2P 2PA 2P% FT FTA
#> 1 71 17090 41.86 87.29 0.48 10.89 31.22 0.349 30.97 56.07 0.552 17.54 24.06
#> FT% ORB DRB TRB AST STL BLK TOV PF PTS +/-
#> 1 0.729 10.54 34.67 45.21 25.1 8.52 6.52 15 20.48 112.14 0
```