Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shiny textAreaInput无法使用fileInput_Shiny - Fatal编程技术网

Shiny textAreaInput无法使用fileInput

Shiny textAreaInput无法使用fileInput,shiny,Shiny,没有显示任何内容。为什么textAreaInput不工作?请尝试下面的代码。使用observeEvent而不是if-else。此外,我还添加了一个条件面板。对于文本输入,如果要求输入以逗号或空格分隔,可以使用“strsplit”简化文本数据到表的转换 audi dodge ford 库(闪亮) 用户界面 audi dodge ford library(shiny) ui <- fluidPage( titlePanel("Uploading Files"),

没有显示任何内容。为什么textAreaInput不工作?

请尝试下面的代码。使用
observeEvent
而不是
if-else
。此外,我还添加了一个条件面板。对于文本输入,如果要求输入以逗号或空格分隔,可以使用“strsplit”简化文本数据到表的转换

audi
dodge
ford
库(闪亮)
用户界面
audi
dodge
ford
library(shiny)
ui <- fluidPage(
  titlePanel("Uploading Files"),
  sidebarLayout(
    sidebarPanel(
      selectInput("choose","Choose file source",choices = c("file","text"),selected = NULL),
      conditionalPanel("input.choose=='file'",fileInput("file1", "Choose CSV File",multiple = TRUE,accept = c("text/csv","text/comma-        separated-values,text/plain", ".csv"))),
      conditionalPanel("input.choose=='text'",
                       p("Enter a comma or space separated list"),
                       textAreaInput("paste", "Or manufacturer",placeholder =  "Paste one manufacturer per line"),)),
      
    mainPanel(tableOutput("contents"))))
server <- function(input, output) {

  observeEvent(input$file1,{
    req(input$file1)
    output$contents=renderTable({data <- as.matrix(mpg)
                                df <- read.delim(input$file1$datapath,header = F)
                                manufacturer <- unique(df[, 1])
                                data[data[, 1] %in% manufacturer, ]})
    })
  
observeEvent(input$paste,{
  req(input$paste)
  mfg=strsplit(input$paste,",| ")
  output$contents=renderTable(data.frame('manfucature'=unlist(mfg)))
  
})
  
  }
shinyApp(ui, server)