【发布时间】:2022-01-24 06:08:02
【问题描述】:
我有五个 R 脚本来源于我在 renderPlot 中运行的闪亮应用程序。每个脚本中包含一系列独特的突变以及 ggplot 代码,以生成具有特定分位数值的箱线图。每个都是接受我的 input$variable 的独特函数。 我想在 Shiny 中获取脚本,并根据用户滑块选择的分位数值循环遍历绘图。 我没有任何问题单独生成每个情节,问题是一起运行它们。 “名称”的每个变量在每个函数中都有唯一的值。所以理想情况下,我想选择一个变量并使用滑块查看它的每个图。 是否有捷径可寻?我试图将滑块输入与每个特定的情节联系起来,但没有任何运气。
source("s_75.R")
source("s_80.R")
source("s_85.R")
source("s_90.R")
source("s_95.R")
# Define UI for pair interaction app ----
ui <- pageWithSidebar(
# App title ----
headerPanel("Set"),
# Sidebar panel for inputs ----
sidebarPanel(# Input: Selector for variable to plot against ----
selectInput("variable", "Name:", qc$S),
sliderInput("quantile", "Quantile Range:",
min = 75, max = 95, value = c(85), step = 5)),
# Main panel for displaying outputs ----
mainPanel(
h1("Header 1"),
plotOutput("plot", width = "100%")
))
# Define server logic to plot various variables against
server <- function(input, output, session) {
output$plot <- renderPlot(s_75(input$variable),
height = 600, width = 800)
output$plot2 <- renderPlot(s_80(input$variable),
height = 600, width = 800)
output$plot3 <- renderPlot(s_85(input$variable),
height = 600, width = 800)
output$plot4 <- renderPlot(s_90(input$variable),
height = 600, width = 800)
output$plot5 <- renderPlot(s_95(input$variable),
height = 600, width = 800)
shinyApp(ui, server)
【问题讨论】: