简体   繁体   中英

R Shiny reactive object as a vector (ggplot)

in my Shiny App I want to have textinput, action button and grapf plotted after clicking action but.

My problem is how to use in reactive in gtrends function (from gtrendsR package).

    ui <- fluidPage(

  textInput("fraza", "Wpisz fraze do wyszukania w Google Trends", "...")  
  ,actionButton("ab", "An action button")
  ,plotOutput("gtr")
)
######################
server <- function(input, output) {
  
library(gtrendsR)  
    
observeEvent(input$ab, {
  output$fraza <- renderText({input$fraza})

  zm <- reactive({input$fraza})
  library(gtrendsR)  
    gtr <- gtrends(zm)
    output$gtr <- renderPlot({plot(gtr)})
                             
                             
  
}) #zamkniecie observe
  
  } #zamkniecie server

  
###################
shinyApp(ui, server)

#################

Could You help me?

The output of the reactive function can be thought of as a function.

when you use zm , you should call it like zm() and you shouldn't have an issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM