PlayerID <- c(1, 2, 3, 4, 5)
Hits <- c(112, 124, 121, 106, 140)
AtBats <- c(400, 450, 380, 500, 402)
BB <- c(50, 60, 19, 150, 55)
Numerator <- Hits + BB
Numerator
## [1] 162 184 140 256 195
Denominator <- AtBats + BB
Denominator
## [1] 450 510 399 650 457
OBP <- Numerator / Denominator
OBP
## [1] 0.3600000 0.3607843 0.3508772 0.3938462 0.4266958
HighestOBP <- max(OBP)
HighestOBP
## [1] 0.4266958
PlayerID[which.max(OBP)]
## [1] 5