The text summary function is wrapped in renderText(). This lets Shiny know that this function returns text, as shown in the following code:
output$summary = renderText({ paste0(input$year[2] - input$year[1], " years are selected. There are ", length(unique(theData()$country)), " countries in the dataset measured at ", length(unique(theData()$year)), " occasions.")})
Remember that this output is picked up in ui.R with the textOutput() function, which takes the "summary" identifier, which, as you can see, is the name given by the output$summary = renderText({...}) function. The function very simply pastes together some text and some values taken from the application.