You're a helpful coding assistant and pair programmer working with a human user. You are…
- User
You're a helpful coding assistant and pair programmer working with a human user.
You are working in R shiny app for web scrapping EU Clinical Trials Register.
Features:
- Select the input option [not fully implemented]
- Select sets of data to scrape [not fully implemented]
- Select the output file format [not fully implemented]
Please ask any clarifying questions before proceeding, if necessary.
This is our current code:
app.R: library(shiny)
Define UI for application that draws a histogram
ui <- shinyUI(fluidPage(
Subtitle
h2("EUCTR Scraper 🪄", align="center"),
Instruction text with hyperlink
div( style = "text-align: center; margin-top: 20px; margin-bottom: 20px;", HTML("This is a web scraper for the EU Clinical Trial Register.") ),
Select input option
selectInput("input_option", "Select the input option:", choices = c("EUCTR search query URL", "List of EudraCT numbers"), selected = "EUCTR search query URL"),
Input box for the URL
textInput("input_var", "Do a trial search on EU Clinical Trials Register website and copy the URL for the search query:", value="Paste here", width="100%"),
Selectize input box with list of options and suboptions
selectizeInput("selection_box", label = "Select sets of data to scrape:", choices = list( "Option 1" = list( "Suboption 1.1" = "suboption1.1", "Suboption 1.2" = "suboption1.2", "Suboption 1.3" = "suboption1.3" ), "Option 2" = list( "Suboption 2.1" = "suboption2.1", "Suboption 2.2" = "suboption2.2" ) # Add more options and suboptions here ), multiple = TRUE, options = list(plugins = list('remove_button')), width = "100%"),
Select the output file format
selectInput("file_format", "Select the output file format:", choices = c("Excel file" = "xlsx", "CSV files" = "csv"), selected = "xlsx"),
‘Start’ button
actionButton("start", "Start"),
Output link to the generated file
uiOutput("output_link") ))
Define server logic
server <- shinyServer(function(input, output) {
Create a reactive value to store the clicked button count
click_count <- reactiveValues(count = 0)
Define a reactive expression for the selected file format
file_format <- reactive({ if (inputfile_format == "csv") { "CSV files" } })
- Assistant
To add a dynamic progress message, you can use the
showNotification()andwithProgress()functions in Shiny. TheshowNotification()function allows you to display messages in the UI, while thewithProgress()function can be used to indicate progress throughout the scraper scripts.Here's how you can implement this in your Shiny app:
- First, you will create a reactiveValues object to store the scraper progress messages:
R