Я создал actionButton RUN demo data
в качестве демонстрации приложения, и мне интересно, как все это сбросить, чтобы пользователь мог начать свой ввод для наборов данных пользователя. Я огляделся вокруг кнопки reset
, но все еще не могу ее понять.
rm(list=ls())
library(tidyverse)
library(shiny)
# Define UI ----
ui <- fluidPage(
tabsetPanel(
#tabPanel-Input
tabPanel("Input", fluid = TRUE,
# tab title ----
titlePanel("Upload data"),
# sidebar layout with input and output tables ----
sidebarLayout(
# sidebar panel for inputs ----
sidebarPanel(
#show ct demo
actionButton("runexample", "RUN demo data"),
# input1: Select a file ----
fileInput("file1", "Count matrix File (.xlsx)",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
#input2: select a file ----
fileInput("file2", "Manifest File (.xlsx)",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
#select column name
selectInput("design", "Column name for analysis", " "),
#select ref group
uiOutput("level0"),
#select study group
uiOutput("level1"),
#action run
actionButton("runbutton", "Run"),
#comment message
p("Click to perform differential gene expression analysis between the selected groups"),
#README link
uiOutput("README"),
#issue report
uiOutput("issue")
),
# Main panel for displaying outputs ----
mainPanel(
# Output: Data file ----
tableOutput("matrix"),
tableOutput("pdat")
)
)
),
#tabPanel-Results
tabPanel("Results", fluid = TRUE,
# App title ----
titlePanel("Download results"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: Choose dataset ----
selectInput("results", "Choose a dataset:",
choices = c("Results", "Normalized matrix")),
# Button
downloadButton("downloadData", "Download")
),
# Main panel for displaying outputs ----
mainPanel(
tableOutput("table")
)
)
),
#tabPanel-Plots
tabPanel("Plots", fluid = TRUE,
fluidRow(
column(width = 8,
plotOutput("plot1", height = 800,
# Equivalent to: click = clickOpts(id = "plot_click")
click = "plot1_click",
brush = brushOpts(
id = "plot1_brush"
)
)
),
column(width = 4,
h4("Brushed points"),
verbatimTextOutput("brush_info")
)
)
)
)
)
# Define Server ----
server <- function(input, output, session) {
#tabPanel-Input
###demo data
####count
set.seed(123)
ctdemo<- t(rmultinom(1000, size = 50, prob = c(rep(0.4, 4), rep(0.6, 4))))
####manifest
pdemo<-data.frame(Samples=paste0("Sample", 1:8),
Treatment=rep(c("DrugA", "DrugB"), each=4))
###display demo count matrix
observeEvent(input$runexample, {
output$matrix <- renderTable({
head(ctdemo, 10)
})
output$pdat <- renderTable({
head(pdemo, 10)
})
observe({
updateSelectInput(session, "design", choices="Treatment")
})
output$level0 <- renderUI({
selectInput("ref0", "Reference group", "DrugA")
})
output$level1 <- renderUI({
selectInput("ref1", "Study group", "DrugB")
})
})
}
shinyApp(ui, server)