-1

I already have a simple defined function process in the R script. I want to design an R shiny app to enter the input keywords. After entering the searching keywords and R shiny will automatically jump to my function I wrote in the R script to get the output and reflect back on the R shiny page.

I am curious on how to connect the R shiny and R script. Also, how to put the input that I entered in R shiny automatic on the function I made.

I am the beginner of R and thanks for helping me.

  • 3
    This reads like a job posting. Are you requesting that somebody do this shiny app for you or do you have a specific shiny question or problem you've encountered when you tried to code this yourself? – cory Jun 10 '19 at 18:46
  • 2
    This question seems far too broad to be a good fit for Stack Overflow. If you want a general introduction to creating a Shiny app, I suggest you check out this educational videos: https://www.rstudio.com/resources/webinars/shiny-developer-conference/ – MrFlick Jun 10 '19 at 18:49
  • @cory It is for personal interest, I am trying to design a search engine based on the database I have. – R beginnnnnner Jun 10 '19 at 18:56

2 Answers2

3

Normally too broad, but I can help you quickly.

source("path/to/my/script.R")


library(shiny)

ui <- fluidPage(

    titlePanel("Run script from Button click"),
    actionButton("script", "Run the Script")
    )


server <- function(input, output) {

    observeEvent(input$script, {
        source("script.R")
    })

}

# Run the application 
shinyApp(ui = ui, server = server)

Load the script with source and use observeEvent to run it.

DSGym
  • 2,807
  • 1
  • 6
  • 18
0

you can put your functions in the main folder of your R shiny app and then use

  source('./functions.R')

in the source to load them

Raha
  • 113
  • 10