我能够通过使用fileInput选项创建一个结构来接受来自用户的输入。我想查看与输出相同的文件。
library(shiny)
ui<-fluidPage(
fileInput(inputId = "ABC", label="Input File", multiple = FALSE, accept = NULL,
width = NULL, buttonLabel = "Browse...",
placeholder = "No file selected"),
dataTableOutput('XX')
)
server<-function(input, output){
output$XX<-renderDataTable(ABC)
#output$XX<-renderDataTable(iris_2)
}
shinyApp(ui, server)
答案 0 :(得分:0)
在应用的服务器部分,将输出更改为:
const spyObj = {
... jasmine.createSpyObj('MyObject', ['spyMethod']),
myProperty: true,
};
spyObj.spyMethod();
expect(spyObj.spyMethod).toHaveBeenCalled();
expect(spyObj.myProperty).toBeTrue();
通过这种方式,该函数知道应使用哪个输入。
答案 1 :(得分:0)
具有actionButton
和observeEvent
控件的解决方案。
library(shiny)
library(DT)
ui <- fluidPage(
fileInput(inputId = "ABC", label = "Input File", multiple = FALSE, accept = NULL,
width = NULL, buttonLabel = "Browse...",
placeholder = "No file selected"),
actionButton(inputId = "submit", label = "Submit"),
dataTableOutput("XX")
)
server <- function(input, output) {
observeEvent( input$submit, {
data <- read.csv(input$ABC$datapath, header = TRUE, sep = ",")
output$XX <- renderDataTable({
datatable(data)
})
})
}
shinyApp(ui, server)