highlighting text on shiny












0















I have a shiny app that a user searches words from a quote database through a textInput and results outputted through htmlOutput.
I want to be able to highlight the matching words within the htmlOutput as shown in the image.



enter image description here



An example of the code is as below:



 library(shiny)
library(shinydashboard)


ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
menuItem("TexSearch", tabName = "Tabs", icon = icon("object-ungroup"))

)
),
dashboardBody(
tabItem(tabName = "Tabs",
fluidRow(
column(width=3,
box(
title="Search ",
solidHeader=TRUE,
collapsible=TRUE,
width=NULL,
textInput("quoteSearch", " Search ", '', placeholder = "Type keyword/statement"),
submitButton("Search")
)
),

column( width=9,
tabBox(
width="100%",
tabPanel("tab1",
htmlOutput("quotesearchdetails")
)))))))

server <- function(input, output) {
output$quotesearchdetails <-renderUI({
outputed=""
author <- c('John Cage','Thomas Carlyle','Elbert Hubbard', 'Albert Einstein')
quote <- c('I cant understand why people are frightened of new ideas. Im frightened of the old ones.','The tragedy of life is not so much what men suffer, but rather what they miss.','The greatest mistake you can make in life is to be continually fearing you will make one.', 'Anyone who has never made a mistake has never tried anything new.')

quotes <- data.frame(author, quote)

if(input$quoteSearch!=""){
words<-strsplit(input$quoteSearch,",")
words<-as.character(words[[1]])
words<-tolower(words)
for(i in 1:length(words)){
quotes<-quotes[
grepl(words[i],quotes$quote),]

}
if (dim(quotes)[1]>0){
for(i in seq(from=1,to=dim(quotes)[1])){

outputed<-paste(outputed,
paste("Author: ",quotes[i,"author"]),
sep="<br/><br/>")
outputed<-paste(outputed,
paste("Quote: ",quotes[i,"quote"]),
sep="<br/><br/>")

}

} else {outputed- "No quotes found."}
}

HTML(outputed)
})


}
shinyApp(ui, server)


I have checked for similar questions and found this one to be close highlight searching text on type react but address when typing and does not address multiple occurences of the word.



Any direction and suggestions are welcome.



  library(shiny)

highlight <- function(text, search) {
x <- unlist(strsplit(text, split = " ", fixed = T))
x[tolower(x) %in% tolower(c(search1, search2))] <- paste0("<mark>",
x[tolower(x) %in% tolower(c(search1, search2))], "</mark>")
paste(x, collapse = " ")
}

shinyApp(
ui = fluidPage(
textInput("search1", "Search"),
textInput("search2", "Search"),
br(), br(),
htmlOutput("some_text")
),
server = function(input, output, session) {
output$some_text <- renderText({
highlight("Author: Albert Einstein<br/>Quote: The greatest mistake you
can make in life is to be continually fearing you will make one", c(input$search1, input$search2) )
})
}
)









share|improve this question





























    0















    I have a shiny app that a user searches words from a quote database through a textInput and results outputted through htmlOutput.
    I want to be able to highlight the matching words within the htmlOutput as shown in the image.



    enter image description here



    An example of the code is as below:



     library(shiny)
    library(shinydashboard)


    ui <- dashboardPage(
    dashboardHeader(),
    dashboardSidebar(
    sidebarMenu(
    menuItem("TexSearch", tabName = "Tabs", icon = icon("object-ungroup"))

    )
    ),
    dashboardBody(
    tabItem(tabName = "Tabs",
    fluidRow(
    column(width=3,
    box(
    title="Search ",
    solidHeader=TRUE,
    collapsible=TRUE,
    width=NULL,
    textInput("quoteSearch", " Search ", '', placeholder = "Type keyword/statement"),
    submitButton("Search")
    )
    ),

    column( width=9,
    tabBox(
    width="100%",
    tabPanel("tab1",
    htmlOutput("quotesearchdetails")
    )))))))

    server <- function(input, output) {
    output$quotesearchdetails <-renderUI({
    outputed=""
    author <- c('John Cage','Thomas Carlyle','Elbert Hubbard', 'Albert Einstein')
    quote <- c('I cant understand why people are frightened of new ideas. Im frightened of the old ones.','The tragedy of life is not so much what men suffer, but rather what they miss.','The greatest mistake you can make in life is to be continually fearing you will make one.', 'Anyone who has never made a mistake has never tried anything new.')

    quotes <- data.frame(author, quote)

    if(input$quoteSearch!=""){
    words<-strsplit(input$quoteSearch,",")
    words<-as.character(words[[1]])
    words<-tolower(words)
    for(i in 1:length(words)){
    quotes<-quotes[
    grepl(words[i],quotes$quote),]

    }
    if (dim(quotes)[1]>0){
    for(i in seq(from=1,to=dim(quotes)[1])){

    outputed<-paste(outputed,
    paste("Author: ",quotes[i,"author"]),
    sep="<br/><br/>")
    outputed<-paste(outputed,
    paste("Quote: ",quotes[i,"quote"]),
    sep="<br/><br/>")

    }

    } else {outputed- "No quotes found."}
    }

    HTML(outputed)
    })


    }
    shinyApp(ui, server)


    I have checked for similar questions and found this one to be close highlight searching text on type react but address when typing and does not address multiple occurences of the word.



    Any direction and suggestions are welcome.



      library(shiny)

    highlight <- function(text, search) {
    x <- unlist(strsplit(text, split = " ", fixed = T))
    x[tolower(x) %in% tolower(c(search1, search2))] <- paste0("<mark>",
    x[tolower(x) %in% tolower(c(search1, search2))], "</mark>")
    paste(x, collapse = " ")
    }

    shinyApp(
    ui = fluidPage(
    textInput("search1", "Search"),
    textInput("search2", "Search"),
    br(), br(),
    htmlOutput("some_text")
    ),
    server = function(input, output, session) {
    output$some_text <- renderText({
    highlight("Author: Albert Einstein<br/>Quote: The greatest mistake you
    can make in life is to be continually fearing you will make one", c(input$search1, input$search2) )
    })
    }
    )









    share|improve this question



























      0












      0








      0








      I have a shiny app that a user searches words from a quote database through a textInput and results outputted through htmlOutput.
      I want to be able to highlight the matching words within the htmlOutput as shown in the image.



      enter image description here



      An example of the code is as below:



       library(shiny)
      library(shinydashboard)


      ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(
      sidebarMenu(
      menuItem("TexSearch", tabName = "Tabs", icon = icon("object-ungroup"))

      )
      ),
      dashboardBody(
      tabItem(tabName = "Tabs",
      fluidRow(
      column(width=3,
      box(
      title="Search ",
      solidHeader=TRUE,
      collapsible=TRUE,
      width=NULL,
      textInput("quoteSearch", " Search ", '', placeholder = "Type keyword/statement"),
      submitButton("Search")
      )
      ),

      column( width=9,
      tabBox(
      width="100%",
      tabPanel("tab1",
      htmlOutput("quotesearchdetails")
      )))))))

      server <- function(input, output) {
      output$quotesearchdetails <-renderUI({
      outputed=""
      author <- c('John Cage','Thomas Carlyle','Elbert Hubbard', 'Albert Einstein')
      quote <- c('I cant understand why people are frightened of new ideas. Im frightened of the old ones.','The tragedy of life is not so much what men suffer, but rather what they miss.','The greatest mistake you can make in life is to be continually fearing you will make one.', 'Anyone who has never made a mistake has never tried anything new.')

      quotes <- data.frame(author, quote)

      if(input$quoteSearch!=""){
      words<-strsplit(input$quoteSearch,",")
      words<-as.character(words[[1]])
      words<-tolower(words)
      for(i in 1:length(words)){
      quotes<-quotes[
      grepl(words[i],quotes$quote),]

      }
      if (dim(quotes)[1]>0){
      for(i in seq(from=1,to=dim(quotes)[1])){

      outputed<-paste(outputed,
      paste("Author: ",quotes[i,"author"]),
      sep="<br/><br/>")
      outputed<-paste(outputed,
      paste("Quote: ",quotes[i,"quote"]),
      sep="<br/><br/>")

      }

      } else {outputed- "No quotes found."}
      }

      HTML(outputed)
      })


      }
      shinyApp(ui, server)


      I have checked for similar questions and found this one to be close highlight searching text on type react but address when typing and does not address multiple occurences of the word.



      Any direction and suggestions are welcome.



        library(shiny)

      highlight <- function(text, search) {
      x <- unlist(strsplit(text, split = " ", fixed = T))
      x[tolower(x) %in% tolower(c(search1, search2))] <- paste0("<mark>",
      x[tolower(x) %in% tolower(c(search1, search2))], "</mark>")
      paste(x, collapse = " ")
      }

      shinyApp(
      ui = fluidPage(
      textInput("search1", "Search"),
      textInput("search2", "Search"),
      br(), br(),
      htmlOutput("some_text")
      ),
      server = function(input, output, session) {
      output$some_text <- renderText({
      highlight("Author: Albert Einstein<br/>Quote: The greatest mistake you
      can make in life is to be continually fearing you will make one", c(input$search1, input$search2) )
      })
      }
      )









      share|improve this question
















      I have a shiny app that a user searches words from a quote database through a textInput and results outputted through htmlOutput.
      I want to be able to highlight the matching words within the htmlOutput as shown in the image.



      enter image description here



      An example of the code is as below:



       library(shiny)
      library(shinydashboard)


      ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(
      sidebarMenu(
      menuItem("TexSearch", tabName = "Tabs", icon = icon("object-ungroup"))

      )
      ),
      dashboardBody(
      tabItem(tabName = "Tabs",
      fluidRow(
      column(width=3,
      box(
      title="Search ",
      solidHeader=TRUE,
      collapsible=TRUE,
      width=NULL,
      textInput("quoteSearch", " Search ", '', placeholder = "Type keyword/statement"),
      submitButton("Search")
      )
      ),

      column( width=9,
      tabBox(
      width="100%",
      tabPanel("tab1",
      htmlOutput("quotesearchdetails")
      )))))))

      server <- function(input, output) {
      output$quotesearchdetails <-renderUI({
      outputed=""
      author <- c('John Cage','Thomas Carlyle','Elbert Hubbard', 'Albert Einstein')
      quote <- c('I cant understand why people are frightened of new ideas. Im frightened of the old ones.','The tragedy of life is not so much what men suffer, but rather what they miss.','The greatest mistake you can make in life is to be continually fearing you will make one.', 'Anyone who has never made a mistake has never tried anything new.')

      quotes <- data.frame(author, quote)

      if(input$quoteSearch!=""){
      words<-strsplit(input$quoteSearch,",")
      words<-as.character(words[[1]])
      words<-tolower(words)
      for(i in 1:length(words)){
      quotes<-quotes[
      grepl(words[i],quotes$quote),]

      }
      if (dim(quotes)[1]>0){
      for(i in seq(from=1,to=dim(quotes)[1])){

      outputed<-paste(outputed,
      paste("Author: ",quotes[i,"author"]),
      sep="<br/><br/>")
      outputed<-paste(outputed,
      paste("Quote: ",quotes[i,"quote"]),
      sep="<br/><br/>")

      }

      } else {outputed- "No quotes found."}
      }

      HTML(outputed)
      })


      }
      shinyApp(ui, server)


      I have checked for similar questions and found this one to be close highlight searching text on type react but address when typing and does not address multiple occurences of the word.



      Any direction and suggestions are welcome.



        library(shiny)

      highlight <- function(text, search) {
      x <- unlist(strsplit(text, split = " ", fixed = T))
      x[tolower(x) %in% tolower(c(search1, search2))] <- paste0("<mark>",
      x[tolower(x) %in% tolower(c(search1, search2))], "</mark>")
      paste(x, collapse = " ")
      }

      shinyApp(
      ui = fluidPage(
      textInput("search1", "Search"),
      textInput("search2", "Search"),
      br(), br(),
      htmlOutput("some_text")
      ),
      server = function(input, output, session) {
      output$some_text <- renderText({
      highlight("Author: Albert Einstein<br/>Quote: The greatest mistake you
      can make in life is to be continually fearing you will make one", c(input$search1, input$search2) )
      })
      }
      )






      shiny shinydashboard






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 3 '18 at 10:20







      R noob

















      asked Nov 26 '18 at 11:17









      R noobR noob

      908




      908
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I am using a simplified example to demo one way to do this. Basically, I have created a function that can look at any text and tag the searched word with <mark> tag. This tag will highlight the searched word in the output.



          My regex skills are limited so the highlight function is not perfect but this approach should put you on the right track. You can research on SO or consider asking a separate question for improving this function.



          library(shiny)

          highlight <- function(text, search) {
          x <- unlist(strsplit(text, split = " ", fixed = T))
          x[tolower(x) == tolower(search)] <- paste0("<mark>", x[tolower(x) == tolower(search)], "</mark>")
          paste(x, collapse = " ")
          }

          shinyApp(
          ui = fluidPage(
          textInput("search", "Search"),
          br(), br(),
          htmlOutput("some_text")
          ),
          server = function(input, output, session) {
          output$some_text <- renderText({
          highlight("Author: Albert Einstein<br/>Quote: The greatest mistake you can make in life is to be continually fearing you will make one", input$search)
          })
          }
          )


          enter image description here






          share|improve this answer


























          • Thank you @Shree for your answer. Just a quick query, can the highlight function be expanded to accommodate two or more searches. By this I mean if I have two textInputs can the highlight function be sued to highlight more than one different words.

            – R noob
            Nov 28 '18 at 13:19











          • yes, should be possible. You can modify function to accept 2 search arguments i.e. function(text, search1, search2) and then change x[tolower(x) == tolower(search)] to x[tolower(x) %in% tolower(c(search1, search2))]

            – Shree
            Nov 28 '18 at 17:06













          • Thanks for this. I have tried it over the past few days and I can't bring it to work. Using the example you gave I have edited the question. Would you be kind and point out what I am doing wrong ?

            – R noob
            Dec 3 '18 at 10:23






          • 1





            1) update function def - highlight(text, search1, search2) and 2) update function call - highlight("Author:...", input$search1, input$search2). At this point I also suggest you to ask a separate question for more specific help.

            – Shree
            Dec 3 '18 at 19:04












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53479963%2fhighlighting-text-on-shiny%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I am using a simplified example to demo one way to do this. Basically, I have created a function that can look at any text and tag the searched word with <mark> tag. This tag will highlight the searched word in the output.



          My regex skills are limited so the highlight function is not perfect but this approach should put you on the right track. You can research on SO or consider asking a separate question for improving this function.



          library(shiny)

          highlight <- function(text, search) {
          x <- unlist(strsplit(text, split = " ", fixed = T))
          x[tolower(x) == tolower(search)] <- paste0("<mark>", x[tolower(x) == tolower(search)], "</mark>")
          paste(x, collapse = " ")
          }

          shinyApp(
          ui = fluidPage(
          textInput("search", "Search"),
          br(), br(),
          htmlOutput("some_text")
          ),
          server = function(input, output, session) {
          output$some_text <- renderText({
          highlight("Author: Albert Einstein<br/>Quote: The greatest mistake you can make in life is to be continually fearing you will make one", input$search)
          })
          }
          )


          enter image description here






          share|improve this answer


























          • Thank you @Shree for your answer. Just a quick query, can the highlight function be expanded to accommodate two or more searches. By this I mean if I have two textInputs can the highlight function be sued to highlight more than one different words.

            – R noob
            Nov 28 '18 at 13:19











          • yes, should be possible. You can modify function to accept 2 search arguments i.e. function(text, search1, search2) and then change x[tolower(x) == tolower(search)] to x[tolower(x) %in% tolower(c(search1, search2))]

            – Shree
            Nov 28 '18 at 17:06













          • Thanks for this. I have tried it over the past few days and I can't bring it to work. Using the example you gave I have edited the question. Would you be kind and point out what I am doing wrong ?

            – R noob
            Dec 3 '18 at 10:23






          • 1





            1) update function def - highlight(text, search1, search2) and 2) update function call - highlight("Author:...", input$search1, input$search2). At this point I also suggest you to ask a separate question for more specific help.

            – Shree
            Dec 3 '18 at 19:04
















          1














          I am using a simplified example to demo one way to do this. Basically, I have created a function that can look at any text and tag the searched word with <mark> tag. This tag will highlight the searched word in the output.



          My regex skills are limited so the highlight function is not perfect but this approach should put you on the right track. You can research on SO or consider asking a separate question for improving this function.



          library(shiny)

          highlight <- function(text, search) {
          x <- unlist(strsplit(text, split = " ", fixed = T))
          x[tolower(x) == tolower(search)] <- paste0("<mark>", x[tolower(x) == tolower(search)], "</mark>")
          paste(x, collapse = " ")
          }

          shinyApp(
          ui = fluidPage(
          textInput("search", "Search"),
          br(), br(),
          htmlOutput("some_text")
          ),
          server = function(input, output, session) {
          output$some_text <- renderText({
          highlight("Author: Albert Einstein<br/>Quote: The greatest mistake you can make in life is to be continually fearing you will make one", input$search)
          })
          }
          )


          enter image description here






          share|improve this answer


























          • Thank you @Shree for your answer. Just a quick query, can the highlight function be expanded to accommodate two or more searches. By this I mean if I have two textInputs can the highlight function be sued to highlight more than one different words.

            – R noob
            Nov 28 '18 at 13:19











          • yes, should be possible. You can modify function to accept 2 search arguments i.e. function(text, search1, search2) and then change x[tolower(x) == tolower(search)] to x[tolower(x) %in% tolower(c(search1, search2))]

            – Shree
            Nov 28 '18 at 17:06













          • Thanks for this. I have tried it over the past few days and I can't bring it to work. Using the example you gave I have edited the question. Would you be kind and point out what I am doing wrong ?

            – R noob
            Dec 3 '18 at 10:23






          • 1





            1) update function def - highlight(text, search1, search2) and 2) update function call - highlight("Author:...", input$search1, input$search2). At this point I also suggest you to ask a separate question for more specific help.

            – Shree
            Dec 3 '18 at 19:04














          1












          1








          1







          I am using a simplified example to demo one way to do this. Basically, I have created a function that can look at any text and tag the searched word with <mark> tag. This tag will highlight the searched word in the output.



          My regex skills are limited so the highlight function is not perfect but this approach should put you on the right track. You can research on SO or consider asking a separate question for improving this function.



          library(shiny)

          highlight <- function(text, search) {
          x <- unlist(strsplit(text, split = " ", fixed = T))
          x[tolower(x) == tolower(search)] <- paste0("<mark>", x[tolower(x) == tolower(search)], "</mark>")
          paste(x, collapse = " ")
          }

          shinyApp(
          ui = fluidPage(
          textInput("search", "Search"),
          br(), br(),
          htmlOutput("some_text")
          ),
          server = function(input, output, session) {
          output$some_text <- renderText({
          highlight("Author: Albert Einstein<br/>Quote: The greatest mistake you can make in life is to be continually fearing you will make one", input$search)
          })
          }
          )


          enter image description here






          share|improve this answer















          I am using a simplified example to demo one way to do this. Basically, I have created a function that can look at any text and tag the searched word with <mark> tag. This tag will highlight the searched word in the output.



          My regex skills are limited so the highlight function is not perfect but this approach should put you on the right track. You can research on SO or consider asking a separate question for improving this function.



          library(shiny)

          highlight <- function(text, search) {
          x <- unlist(strsplit(text, split = " ", fixed = T))
          x[tolower(x) == tolower(search)] <- paste0("<mark>", x[tolower(x) == tolower(search)], "</mark>")
          paste(x, collapse = " ")
          }

          shinyApp(
          ui = fluidPage(
          textInput("search", "Search"),
          br(), br(),
          htmlOutput("some_text")
          ),
          server = function(input, output, session) {
          output$some_text <- renderText({
          highlight("Author: Albert Einstein<br/>Quote: The greatest mistake you can make in life is to be continually fearing you will make one", input$search)
          })
          }
          )


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 28 '18 at 17:03

























          answered Nov 27 '18 at 0:57









          ShreeShree

          3,5161424




          3,5161424













          • Thank you @Shree for your answer. Just a quick query, can the highlight function be expanded to accommodate two or more searches. By this I mean if I have two textInputs can the highlight function be sued to highlight more than one different words.

            – R noob
            Nov 28 '18 at 13:19











          • yes, should be possible. You can modify function to accept 2 search arguments i.e. function(text, search1, search2) and then change x[tolower(x) == tolower(search)] to x[tolower(x) %in% tolower(c(search1, search2))]

            – Shree
            Nov 28 '18 at 17:06













          • Thanks for this. I have tried it over the past few days and I can't bring it to work. Using the example you gave I have edited the question. Would you be kind and point out what I am doing wrong ?

            – R noob
            Dec 3 '18 at 10:23






          • 1





            1) update function def - highlight(text, search1, search2) and 2) update function call - highlight("Author:...", input$search1, input$search2). At this point I also suggest you to ask a separate question for more specific help.

            – Shree
            Dec 3 '18 at 19:04



















          • Thank you @Shree for your answer. Just a quick query, can the highlight function be expanded to accommodate two or more searches. By this I mean if I have two textInputs can the highlight function be sued to highlight more than one different words.

            – R noob
            Nov 28 '18 at 13:19











          • yes, should be possible. You can modify function to accept 2 search arguments i.e. function(text, search1, search2) and then change x[tolower(x) == tolower(search)] to x[tolower(x) %in% tolower(c(search1, search2))]

            – Shree
            Nov 28 '18 at 17:06













          • Thanks for this. I have tried it over the past few days and I can't bring it to work. Using the example you gave I have edited the question. Would you be kind and point out what I am doing wrong ?

            – R noob
            Dec 3 '18 at 10:23






          • 1





            1) update function def - highlight(text, search1, search2) and 2) update function call - highlight("Author:...", input$search1, input$search2). At this point I also suggest you to ask a separate question for more specific help.

            – Shree
            Dec 3 '18 at 19:04

















          Thank you @Shree for your answer. Just a quick query, can the highlight function be expanded to accommodate two or more searches. By this I mean if I have two textInputs can the highlight function be sued to highlight more than one different words.

          – R noob
          Nov 28 '18 at 13:19





          Thank you @Shree for your answer. Just a quick query, can the highlight function be expanded to accommodate two or more searches. By this I mean if I have two textInputs can the highlight function be sued to highlight more than one different words.

          – R noob
          Nov 28 '18 at 13:19













          yes, should be possible. You can modify function to accept 2 search arguments i.e. function(text, search1, search2) and then change x[tolower(x) == tolower(search)] to x[tolower(x) %in% tolower(c(search1, search2))]

          – Shree
          Nov 28 '18 at 17:06







          yes, should be possible. You can modify function to accept 2 search arguments i.e. function(text, search1, search2) and then change x[tolower(x) == tolower(search)] to x[tolower(x) %in% tolower(c(search1, search2))]

          – Shree
          Nov 28 '18 at 17:06















          Thanks for this. I have tried it over the past few days and I can't bring it to work. Using the example you gave I have edited the question. Would you be kind and point out what I am doing wrong ?

          – R noob
          Dec 3 '18 at 10:23





          Thanks for this. I have tried it over the past few days and I can't bring it to work. Using the example you gave I have edited the question. Would you be kind and point out what I am doing wrong ?

          – R noob
          Dec 3 '18 at 10:23




          1




          1





          1) update function def - highlight(text, search1, search2) and 2) update function call - highlight("Author:...", input$search1, input$search2). At this point I also suggest you to ask a separate question for more specific help.

          – Shree
          Dec 3 '18 at 19:04





          1) update function def - highlight(text, search1, search2) and 2) update function call - highlight("Author:...", input$search1, input$search2). At this point I also suggest you to ask a separate question for more specific help.

          – Shree
          Dec 3 '18 at 19:04




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53479963%2fhighlighting-text-on-shiny%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Ottavio Pratesi

          Tricia Helfer

          15 giugno