Shiny App for MBA Interviews

[This article was first published on En El Margen - R-English, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A couple of weeks ago I attended some interviews as part of my process for admission into an MBA program. While most candidates would pore over the possible questions and then try to teach them to a third party to help them with a mock interview, I decided to expedite the process by building a shiny app in R.

In the name of helping anyone out there who knows R and is applying to an MBA (I know it is probably very few people), here is the code and a simple explanation of my workflow.


First, you will need an excel with all the possible questions to ask. I compiled one here. You place this excel in the folder with the ui.R and server.R files. When a button is pressed on the app (the “score”), the shiny app will export a very small text file into that folder. This file will be separated by pipes and have 6 columns and one row: each indicating what question and school it is and the subjective score given by the interviewer to the question.

When you want to analyze the results, you simply import each file and rbind them to have a nifty data.frame. I’ll also leave the code to do this later on.

Now, on to the code.


Change it as you wish. There is a timer, that will indicate when time is running more the standard the interview suggests.

d <- read_excel("qs.xlsx")
jsResetCode <- "shinyjs.reset = function() {history.go(0)}"

shinyServer(function(input, output, session) {
  EventTime <- Sys.time()
  qqt <- reactive({
    if(input$response=="To interviewer"){
      d <- d %>% filter(RESPONSE=="To Interviewer")
      d <- d %>% filter(RESPONSE=="To applicant")
    qs <- d$Q
    qn <- sample(row.names(d),1)
    qr <- qs[as.numeric(qn)]
    if(grepl(pattern = "(\\[SCHOOL\\])", x = qr)){
      qr <- gsub(pattern = "(\\[SCHOOL\\])", replacement = input$school, x = qr)
    as.character(paste0("Q",qn,": ",qr))
  output$qqt2 <- renderText({ 
    txt <- qqt()
  output$eventTimeRemaining <- renderUI({
    invalidateLater(1000, session)
    tm <- as.numeric(round(difftime(
      Sys.time(), EventTime, units = 'secs')))
    HTML(paste0("Elapsed time: ", ifelse(tm<60, paste0(tm, " seconds."), 
                                    paste0(tm%/%60, ":", tm%%60, " mins."))))
      HTML(paste0('<p style="color:#9f1317;"><strong>',paste0("Time-up!! (", ifelse(tm<60, paste0(tm, " seconds)."), 
                                      paste0(tm%/%60, ":", tm%%60, " mins).")))),'</strong></p>')
  observeEvent(input$reset, {
  observeEvent(input$reset_button, {js$reset()})  
  observeEvent(input$submit, {
    tm <- as.numeric(round(difftime(
      Sys.time(), EventTime, units = 'secs')))
    nq <- substr(as.character(qqt()), start = 1, 
           stop = gregexpr(pattern = ":", qqt())[[1]][1]-1)
    dtm <- data.frame("School" = input$school, 
                       "Seconds" = tm,
                       "Question" = qqt(),
                       "Number" = nq,
                       "Fluid" = input$score1, 
                       "Content" = input$score2,
                      "Hour" = Sys.time(),
                      "Date" = Sys.Date(),
                      "Type" = "New")
    nm <- paste0(Sys.Date(),
                 gsub(pattern = ":",
                      replacement = "_",
                      x = substr(Sys.time(),12,19)))
    write.table(dtm, file = paste0("Interviews_", nm, ".txt"), 
                sep = "|", row.names = FALSE)


jsResetCode <- "shinyjs.reset = function() {history.go(0)}"

  # Application title
  titlePanel("MBA Interview Questions"),

  # Sidebar with a slider input for number of bins
      sliderInput("NormalTime", "Minutes per response:",
                  min = 0, max = 60, value = 2
      selectInput("response", "Question type:",
                  c("To applicant","To interviewer")),
          # you can select which schools here...        
      selectInput("school", "School:",
                  c("School 1","School 2")),
      HTML('<h4> Typical Methods for Behavioural Questions </h4> <br/>
           <h4> <strong> STAR: </strong><h4> <br/>
          <strong>S</strong>ituation: indentify the situation <br/>
          <strong>T</strong>ask: identify task or project <br/>
          <strong>A</strong>ction: describe what you did <br/>
          <strong>R</strong>esult: summarize the results <br/>
          <h4> <strong> CAR: </strong><h4> </ br>
          <strong>C</strong>ontext: describe the context <br/>
           <strong>A</strong>ction: describe what you did <br/>
           <strong>R</strong>esult: summarize the results <br/>
      HTML('<h1> Question </h1>'),
      sliderInput("score1", "Fluidity and Security:",
                  min = 0, max = 10, value = 5
      sliderInput("score2", "Content:",
                  min = 0, max = 10, value = 5
      extendShinyjs(text = jsResetCode),
      actionButton("reset_button", "New Question"),
      actionButton("submit", "Score")

Import to analyze

This is the code used to import all of the files starting with “Interviews” from the folder.

LoadManyTxt <- function(regex, separator = "|"){
  a <- list.files()[grepl(pattern = regex,
  datos <- NULL
  for(i in 1:length(a)){
    temp <-
      a[i], sep = separator,
      stringsAsFactors = FALSE))
    print(paste0("Importing... ", a[i]))
      temp$Hora <- NA
      temp$Fecha <- NA
      temp$Tipo <- "Previous"
    datos <-, temp)
    print(paste("Data: ", length(datos[,1])," rows"))
# when in the folder, just do...
d <- LoadManyTxt("Interviews_")

It might seem intense, but this definitely saved me a few hours. As for the outcome of the interviews, I was invited to join two of my school choices, so it all worked out! Although, having gone through the experience, I think the old mantra: “be yourself” is probably better advice than using this app, so use at your own risk!

To leave a comment for the author, please follow the link and comment on their blog: En El Margen - R-English. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)