Question 1 Now, you must complete the problem below which represents a similar case scenario. You may use the steps that we executed in Case-scenario 1 as a template for your solution.
This is the sixth season of outfielder Juan Soto in the majors. If during the first five seasons he received 79, 108,41,145, and 135 walks, how many does he need on this season for his overall number of walks per season to be at least 100?
# Walks in the first five seasons
walks_before <- c(79, 108, 41, 145, 135)
wanted_walks <- 100
n_seasons <- 6
x_6 <- n_seasons * wanted_walks - sum(walks_before)
x_6
## [1] 92
Question 2 The average salary of 7 basketball players is 102,000 dollars a week and the average salary of 9 NFL players is 91,000. Find the mean salary of all 16 professional players.
n_1 <- 7
n_2 <- 9
y_1 <- 102000
y_2 <- 91000
# Mean salary overall
salary_ave <- (n_1 * y_1 + n_2 * y_2) / (n_1 + n_2)
salary_ave
## [1] 95812.5
Question 3 Use the skills learned in case scenario number 3 on one the following data sets. You may choose only one dataset. They are both available in Canvas.
doubles_hit.csv and triples_hit.csv
getwd()
## [1] "C:/Users/henry/Downloads"
doubles_hit <- read.csv("doubles_hit.csv", header = TRUE, sep = ",")
doubles_hits <- doubles_hit$doubles_hit
# Calculate mean
doubles_mean <- mean(doubles_hits)
doubles_mean
## [1] 23.55
# Calculate median
doubles_median <- median(doubles_hits)
doubles_median
## [1] 23.5
# Calculate standonard deviati
doubles_sd <- sd(doubles_hits)
doubles_sd
## [1] 13.37371
# Percentage within one standard deviation
doubles_w1sd <- sum(abs(doubles_hits - doubles_mean) / doubles_sd < 1) / length(doubles_hits)
doubles_w1sd
## [1] 0.58
doubles_w1sd - 0.68
## [1] -0.1
# Percentage within two standard deviations
doubles_w2sd <- sum(abs(doubles_hits - doubles_mean) / doubles_sd < 2) / length(doubles_hits)
doubles_w2sd
## [1] 1
# Difference from empirical
doubles_w2sd - 0.95
## [1] 0.05
# Percentage within three standard deviations
doubles_w3sd <- sum(abs(doubles_hits - doubles_mean) / doubles_sd < 3) / length(doubles_hits)
doubles_w3sd
## [1] 1
# Difference from empirical
doubles_w3sd - 0.9973
## [1] 0.0027
hist(doubles_hits, xlab = "Doubles Hit", col = "green", border = "red",
xlim = c(0, 50), ylim = c(0,25), breaks = 5,
main = "Histogram of Doubles Hit")