This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

plot(cars)

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

log(10)
## [1] 2.302585
log10(10)
## [1] 1
log10(100)
## [1] 2
log10(1000)
## [1] 3

#log base 5 of 10

log(10, base = 5)
## [1] 1.430677

#log of 10

log(10)
## [1] 2.302585
log10(10)
## [1] 1
#Batting Average=(No. of Hits)/(No. of At Bats)
#What is the batting average of a player that bats 29 hits in 112 at bats?
BA=(29)/(112)
BA
## [1] 0.2589286
#Question_2:What is the batting average of a player that bats 42 hits in 212 at bats?
BA=(42)/(212)
BA=round(BA, digits=3)
BA
## [1] 0.198

#On Base Percentage #OBP=(H+BB+HBP)/(At Bats+BB+HBP+SF) #Let us compute the OBP for a player with the following general stats #AB=515,H=172,BB=84,HBP=5,SF=6

OBP=(172+84+5)/(515+84+5+6)
OBP
## [1] 0.4278689
On_Base_Percentage=round(OBP,digits = 3)
On_Base_Percentage
## [1] 0.428

#Question_3:Compute the OBP for a player with the following general stats: #AB=565,H=156,BB=65,HBP=3,SF=7

OBP=(156+65+3)/(565+65+3+7)
OBP
## [1] 0.35