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.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
HR_before <- c(11, 13, 12) # Average Number of Home-runs per season wanted wanted_HR <- 20 # Number of seasons n_seasons <- 4 # Needed Home-runs on season 4 x_4 <- n_seasons*wanted_HR - sum(HR_before) # Minimum number of Home-runs needed by Robert x_4
Robert_HRs <- c(11, 13, 12,44) # Find mean mean(Robert_HRs)
sd(Robert_HRs)
max(Robert_HRs)
min(Robert_HRs)
summary(Robert_HRs)
n_1 <- 10 n_2 <- 4 y_1 <- 72000 y_2 <- 84000 # Mean salary overall salary_ave <- (n_1y_1 + n_2y_2)/(n_1+n_2) salary_ave
contract_length <- read.table(“allcontracts.csv”, header = TRUE, sep = “,”) contract_years <- contract_length$years
contracts_mean <- mean(contract_years) contracts_mean
contracts_median <- median(contract_years) contracts_median
contracts_n <- length(contract_years) # Find standard deviation contracts_sd <- sd(contract_years)
contracts_w1sd <- sum((contract_years - contracts_mean)/contracts_sd < 1)/ contracts_n # Percentage of observation within one standard deviation of the mean contracts_w1sd
contracts_w1sd - 0.68
contracts_w2sd <- sum((contract_years - contracts_mean)/ contracts_sd < 2)/contracts_n contracts_w2sd
contracts_w2sd - 0.95
contracts_w3sd <- sum((contract_years - contracts_mean)/ contracts_sd < 3)/contracts_n contracts_w3sd
contracts_w3sd - 0.9973
hist(contract_years,xlab = “Years Left in Contract”,col = “green”,border = “red”, xlim = c(0,8), ylim = c(0,225), breaks = 5)