Reputation: 1456
Let's say I have the following output of text. Using Quanteda kwic()
, I want to find verbatims that match a pattern. I want to be able to show the output as a single line and not 3 columns so I reshape to and merge them together. I want to be able highlight the pattern word in the string. Is this at all do-able? and If so, how?
# Define UI for app that draws a histogram ----
ui <- fluidPage(
# App title ----
titlePanel("Hello Shiny!"),
# Main panel for displaying outputs ----
mainPanel(
# Output: Histogram ----
fluidRow(DT::dataTableOutput("table1"))
)
)
server= function(input,output){
output$table1 = renderDataTable({
y = kwic(x = data_corpus_inaugural,pattern = 'united',window = 10,valuetype = 'regex')
y = as.data.table(y)
y = y[,4:6]
y$new = do.call('paste',y)
y = y[,!c(1:3)]
})
}
shinyApp(ui,server)
Upvotes: 5
Views: 1055
Reputation: 1456
Shout out to @MLavoie for the link in the comments.
To highlight selected text, repalce the 'da' with the input provided by the user.
datatable(mtcars2, options = list(searchHighlight = TRUE, search = list(search = 'da')))
Upvotes: 2