#Question_1: Compute the log base 5 of 10 and the log of 10.

log10(5)
## [1] 0.69897
log(10)
## [1] 2.302585

#Question_2:What is the batting average of a player that bats 42 hits in 212 at bats?

BA=(42)/(212)
BA
## [1] 0.1981132

#Question_3:Compute the OBP for a player with the following general stats: #AB=565,H=156,BB=65,HBP=3,SF=7 #On Base Percentage #OBP=(H+BB+HBP)/(At Bats+BB+HBP+SF)

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

#Question_4: Define two vectors,runs_per_9innings and hits_per_9innings, each with five elements.

runs_per_9innings <- c(4, 12, 18, 9, 10)
runs_per_9innings
## [1]  4 12 18  9 10
hits_per_9innings <- c(13, 14, 6, 18, 11)
hits_per_9innings
## [1] 13 14  6 18 11

#Question_5: Get the first element of hits_per_9innings.

hits_per_9innings[1]
## [1] 13

#Question_6: Get the last element of hits_per_9innings.

hits_per_9innings[5]
## [1] 11
getMode <- function(x) {
  ux <- unique(x)
  ux[which.max(tabulate(match(x, ux)))]
}

#Question_7: Find the most frequent value of hits_per_9innings.

getMode(hits_per_9innings)
## [1] 13

#Question_8: Summarize the following survey with the table() command: #What is your favorite day of the week to watch baseball? A total of 10 fans submitted this survey. #Saturday, Saturday, Sunday, Monday, Saturday,Tuesday, Sunday, Friday, Friday, Monday

game_day<-c("Saturday", "Saturday", "Sunday", "Monday", "Saturday","Tuesday", "Sunday", "Friday", "Friday", "Monday")
table(game_day)
## game_day
##   Friday   Monday Saturday   Sunday  Tuesday 
##        2        2        3        2        1

#Question_9: What is the most frequent answer recorded in the survey? Use the getMode function to compute results.

getMode(game_day)
## [1] "Saturday"