#HOW TO USE #Execute the script and call trainee() function from console #MASS library is needed for chi square require(MASS) library(MASS) #Create function called "fun" trainee <- function(){ #Get observed successful sales attempts and convert to integer obs_s <- readline(prompt="Successfull attemmpts from 100: ") obs_s <- strtoi(obs_s) #Calculate observed failed sales attempts obs_f <- 100 - obs_s #Create a vector for expected values obs <- c(obs_f,obs_s) #Create a vector for expected probabilities exp <- c(0.9,0.1) #Do the chi-test test <- chisq.test(obs,p=exp) #Print p-value cat("Probability of chance: ",test$p.value,"\n") #Probability is stored in test$p.value #HIRE if a person is better than the average with 95% confidence #FIRE if a person is worse than the average with 95% confidence #ELSE give a new chance #Determine the level of significance to 5% sl <- 1-0.95 #Probability is significant and has more than average calls if(test$p.value10){ cat("HIRE") #Significant with less than average calls }else if(test$p.value