# Load the dataset from the Excel file
RandomRB <- readxl::read_excel("RandomRB.xlsx")
## New names:
## • `TD` -> `TD...4`
## • `Yds` -> `Yds...8`
## • `Yds` -> `Yds...12`
## • `TD` -> `TD...14`
# Check current column names
colnames(RandomRB)
##  [1] "Rk"            "Player"        "GS"            "TD...4"       
##  [5] "T.Fumbles"     "FR"            "FL"            "Yds...8"      
##  [9] "FRTD"          "FF"            "Att"           "Yds...12"     
## [13] "Y/A"           "TD...14"       "Y/G"           "T/FL Ratio"   
## [17] "T/FL per Game"
# Rename specific columns
colnames(RandomRB)[colnames(RandomRB) == "TD...4"] <- "TD"
colnames(RandomRB)[colnames(RandomRB) == "Yds...8"] <- "YdsLstF"
colnames(RandomRB)[colnames(RandomRB) == "Yds...12"] <- "YdsGain"
# Remove the 'TD...14' column
RandomRB <- subset(RandomRB, select = -c(TD...14))
# Check updated column names to confirm the changes
colnames(RandomRB)
##  [1] "Rk"            "Player"        "GS"            "TD"           
##  [5] "T.Fumbles"     "FR"            "FL"            "YdsLstF"      
##  [9] "FRTD"          "FF"            "Att"           "YdsGain"      
## [13] "Y/A"           "Y/G"           "T/FL Ratio"    "T/FL per Game"
# Filter players with at least 100 games started
filtered_data <- subset(RandomRB, GS >= 100)
# Sort data by T/FL per Game and select top 10 and bottom 10
sorted_data <- filtered_data[order(filtered_data$`T/FL per Game`, decreasing = TRUE), ]
top_10 <- head(sorted_data, 10)
bottom_10 <- tail(sorted_data, 10)

ggplot(top_10, aes(x = reorder(Player, `T/FL per Game`), y = `T/FL per Game`)) +
  geom_bar(stat = "identity", fill = "blue") +
  coord_flip() +
  xlab("Player") +
  ylab("T/FL per Game") +
  ggtitle("Top 10 Players in T/FL per Game with at least 100 GS")

ggplot(bottom_10, aes(x = reorder(Player, `T/FL per Game`), y = `T/FL per Game`)) +
  geom_bar(stat = "identity", fill = "brown") +
  coord_flip() +
  xlab("Player") +
  ylab("T/FL per Game") +
  ggtitle("Bottom 10 Players in T/FL per Game with at least 100 GS")

knitr::kable(top_10, caption = "Top 10 Players in T/FL per Game with at least 100 GS")
Top 10 Players in T/FL per Game with at least 100 GS
Rk Player GS TD T.Fumbles FR FL YdsLstF FRTD FF Att YdsGain Y/A Y/G T/FL Ratio T/FL per Game
56 Tom Rathman 107 26 7 6 1 12 0 0 544 2020 3.7 15.4 26.000000 0.2429907
68 Mark Ingram 100 65 19 7 12 1 0 0 1817 8111 4.5 52.0 5.416667 0.0541667
64 Stephen Davis 102 65 25 13 12 0 0 0 1945 8052 4.1 56.3 5.416667 0.0531046
54 Clinton Portis 108 75 26 11 15 -11 0 1 2230 9923 4.4 87.8 5.000000 0.0462963
57 Ezekiel Elliott 106 71 24 9 15 -7 0 0 2052 8850 4.3 74.4 4.733333 0.0446541
49 William Henderson 112 5 6 5 1 0 0 0 123 426 3.5 2.3 5.000000 0.0446429
11 LaDainian Tomlinson 155 145 31 9 22 0 0 0 3174 13684 4.3 80.5 6.590909 0.0425220
6 Curtis Martin 166 90 29 14 15 -9 0 0 3518 14101 4.0 83.9 6.000000 0.0361446
17 Steven Jackson 147 69 23 10 13 -9 0 0 2764 11438 4.1 71.5 5.307692 0.0361068
55 Craig Heyward 107 30 16 8 8 0 0 0 1031 4301 4.2 28.9 3.750000 0.0350467
knitr::kable(bottom_10, caption = "Bottom 10 Players in T/FL per Game with at least 100 GS")
Bottom 10 Players in T/FL per Game with at least 100 GS
Rk Player GS TD T.Fumbles FR FL YdsLstF FRTD FF Att YdsGain Y/A Y/G T/FL Ratio T/FL per Game
3 Walter Payton 184 110 86 21 65 0 0 NA 3838 16726 4.4 88.0 1.6923077 0.0091973
33 Joe Perry 132 61 66 15 51 6 0 NA 1852 9161 4.9 54.2 1.1960784 0.0090612
16 Keith Byars 150 23 29 12 17 20 0 0 863 3107 3.6 17.8 1.3529412 0.0090196
36 O.J. Simpson 129 61 62 8 54 0 0 NA 2404 11236 4.7 83.2 1.1296296 0.0087568
61 Mack Strong 104 5 10 4 6 0 0 0 230 909 4.0 4.5 0.8333333 0.0080128
37 Kyle Juszczyk 126 5 7 2 5 14 0 1 62 211 3.4 1.2 1.0000000 0.0079365
7 Franco Harris 162 91 90 15 75 -18 0 NA 2949 12120 4.1 70.1 1.2133333 0.0074897
14 Tony Dorsett 152 77 90 17 73 33 1 NA 2936 12739 4.3 73.6 1.0547945 0.0069394
67 Dexter Bussey 100 18 36 10 26 0 0 NA 1203 5105 4.2 34.0 0.6923077 0.0069231
30 Tony Richardson 133 15 5 7 -2 0 0 0 429 1727 4.0 7.4 -7.5000000 -0.0563910

This code will load your data, perform the necessary preprocessing (like renaming and removing columns), conduct the analysis to find the top 10 and bottom 10 players, create bar charts for these players, and finally, generate tables showing their statistics. Make sure your RandomRB.xlsx file is in the current working directory, or provide the correct path to the file. When you knit this document in RStudio or a similar interface, it should produce an HTML document with all these elements.