我写过一个闪亮的应用程序来对RMarkdown文档进行一些计算。在ui.R中,有一个条件是要插入多少单个fileinput作为输入文件。但由于某种原因,Rmarkdown只读取最后一个文件。我知道我可以使用多个文件,但我想避免文件的顺序不正确的情况。另外,我想我正在调用正确的数据路径行。当我删除条件并且字面上有4个输入文件时,它可以正常工作。
shinyUI(
fluidPage(
titlePanel("Drift Report"),
selectInput("n",
"Number of files:",
choices = c(1,2,3,4)),
checkboxInput("d", label = "Data Summary", value = FALSE),
checkboxInput("k", label = "Drift Plots", value = FALSE),
radioButtons("p", label = "Plot Type",
choices = list("Point Plot" = 1, "Cumm Plot"=2, "Both - Side by Side"=3, "Both - One underneath the Other"=4),selected = NULL,inline=TRUE),
sliderInput("s","No of Plots", min = 1, max = 50, value = 10, width = "40%"),
submitButton("Apply Changes"),
conditionalPanel(
condition = "input.n == 1",
fileInput("dat","File Upload for Analysis", accept = ".eff")
),
conditionalPanel(
condition = "input.n == 2",
fileInput("dat","1st File Upload for Analysis"),
fileInput("dat3","2nd File Upload for Analysis")
),
conditionalPanel(
condition = "input.n == 3",
fileInput("dat","1st File Upload for Analysis"),
fileInput("dat3","2nd File Upload for Analysis"),
fileInput("dat4","3rd File Upload for Analysis")
),
conditionalPanel(
condition = "input.n == 4",
fileInput("dat","1st File Upload for Analysis"),
fileInput("dat3","2nd File Upload for Analysis"),
fileInput("dat4","3rd File Upload for Analysis"),
fileInput("dat5","4th File Upload for Analysis")
),
uiOutput('markdown')
)
)
options(shiny.maxRequestSize=30*1024^2)
shinyServer(function(input, output) {
library(shiny)
library(markdown)
library(knitr)
output$markdown <- renderUI({
HTML(markdown::markdownToHTML(knit('RMarkdown_pdf3.Rmd', quiet = TRUE)))
})
})
当我一个接一个地做丑陋的方式时,它运作良好
shinyUI(
fluidPage(
titlePanel("Drift Report"),
selectInput("n",
"Number of files:",
choices = c(1,2,3,4)),
checkboxInput("d", label = "Data Summary", value = FALSE),
checkboxInput("k", label = "Drift Plots", value = FALSE),
radioButtons("p", label = "Plot Type",
choices = list("Point Plot" = 1, "Cumm Plot"=2, "Both - Side by Side"=3, "Both - One underneath the Other"=4),selected = NULL,inline=TRUE),
sliderInput("s","No of Plots", min = 1, max = 100, value = 10, width = "40%"),
submitButton("Apply Changes"),
HTML('<br>'),
helpText(h4("Upload only the necessary files")),
fileInput("dat","1st File Upload", accept = ".eff"),
fileInput("dat3","2nd File upload",accept = ".eff"),
fileInput("dat4","3rd File upload",accept = ".eff"),
fileInput("dat5","4th File upload",accept = ".eff"),
HTML('<hr>'),
uiOutput('markdown')
)
)
这就是我要求上传文件的方式:
dat <- data.f(input$dat[[1, 'datapath']])
任何想法在条件设置下可能会被打破? 提前谢谢