Hi!
I'm a begginer at R and Shiny.
I just want that the actionButton works when I click directioning the code ahead...
It's a interface where the user makes the archive.csv upload, and click on "Submmit" botton and the things continue to work ahead.
This is the code:
library(shiny)
library(bslib)
library(rmarkdown)
light <- bs_theme()
# user interface
ui <- fluidPage(
theme = light,
tags$title("WS_musteR"),
titlePanel("MusteR"),
includeCSS("html/style.css"),
includeHTML("html/index.html"),
sidebarLayout(
sidebarPanel(
fileInput("filecsv", "Insira a tabela CSV",
multiple = FALSE,
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"),
width = NULL,
buttonLabel = "Browse...",
placeholder = "No file selected"
),
actionButton("action", "Submeter", class = "btn-success"),
),
mainPanel(
tableOutput("contents")
#plotOutput(outputId = "distPlot")
),
),
)
# server side
server <- function(input, output) {
output$contents <- renderTable({
observeEvent(input$filecsv, {
file <- input$filecsv
if (is.null(file)) {
stop("Entrada Vazia!")
} else {
ext <- tools::file_ext(file$datapath)
req(file)
validate(need(ext == "csv", "ERROR: Please upload a .csv file!"))
x <- read.csv(file$datapath, header = input$header)
print("Running code...")
source(paste0(bibpath,"main-ligs-v1_WS.R"))
}})
})
}
shinyApp(ui = ui, server = server)