Shiny app fails with "argument 1 (type 'closure') cannot be handled by 'cat'" - what does this mean?
<p>I am building a Shiny app that takes a user's text input, compares the last two words to a data frame of trigrams to predict the most likely next word.  In server.R below the output of the triPred function which I am trying to ouptut is a single word.  When I load this app I get the following error after I type some text into the app - 'argument 1 (type 'closure') cannot be handled by 'cat' - which appears to be related to the final line in server.R  As this is just a single word, I am unclear what is failing with 'cat' ie concatenate.  </p>

<p>server.R</p>

<pre><code>library(stringr)

shinyServer(function(input, output) {

    triSplit &lt;- function(input) {
            el &lt;- unlist(str_split(input," "))
            bigram &lt;- paste(el[length(el)-1],el[length(el)])
            return(bigram)
    }

    triPred &lt;- function(input) {
            ## pulls out end words that match the input bigram
            temp_wf_T &lt;- wf_T[wf_T$start == triSplit(input),]
            ##Picks one of the best options at random based on count
            ans &lt;- sample(temp_wf_T$end[temp_wf_T$count == max(temp_wf_T$count)],1)
            return(ans) }

    ##Read in a dataframe of bigrams, their possible completions, and counts of occurence
    wf_T&lt;-readRDS("C:/Users/LTM/DataScienceCertificateCapstone/ShinyTest/data/tdm.rds")
    ##Runs the triPred function to guess the next most likely word
    ans &lt;- reactive(triPred(input$sent))
    ##generates an output variable to display
    output$out &lt;- renderText({ans})
    })
</code></pre>

<p>ui.R</p>

<pre><code>library(shiny)

shinyUI(fluidPage(
    titlePanel(h1("My Shiny App", align = "center")),
    sidebarLayout(
            sidebarPanel(helpText("Please enter a sentence you would like me to complete"),
            textInput("sent", label = "sentence")),
            ##########
            mainPanel(h1("Best Guess"),
            br(),
            textOutput("out")
            )
    )
))
</code></pre>