Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.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
R 闪亮应用程序-从输入文本加载带有列名的csv_R_Csv_Import_Shiny - Fatal编程技术网

R 闪亮应用程序-从输入文本加载带有列名的csv

R 闪亮应用程序-从输入文本加载带有列名的csv,r,csv,import,shiny,R,Csv,Import,Shiny,如果header=FALSE,我试图从输入文本加载带有列名称的csv文件。col.names(c()中的textInput有点奇怪。当我将textInput输入为“a”、“b”、“x”时,输入文本被读取为“\“a\”、“b\”、“x\” 库(闪亮) shinyServer(功能(输入、输出){ colm我怀疑这是一个有光泽的问题。只需在直接的R中测试它。它在R中工作…请参阅下面使用的代码..var library(shiny) shinyServer(function(input, outp

如果header=FALSE,我试图从输入文本加载带有列名称的csv文件。col.names(c()中的textInput有点奇怪。当我将textInput输入为“a”、“b”、“x”时,输入文本被读取为“\“a\”、“b\”、“x\”

库(闪亮)
shinyServer(功能(输入、输出){

colm我怀疑这是一个有光泽的问题。只需在直接的R中测试它。它在R中工作…请参阅下面使用的代码..var
library(shiny)
  shinyServer(function(input, output) {
  colm <- renderText({input$cols})
  head <- renderText({input$header})

contents <- reactive({ 

    infile <- input$file1
    if (head() =="TRUE") {        
    if (is.null(input$file1)) {return(NULL)}
    read.csv(infile$datapath)}
  else  
    {  
      if (is.null(input$file1)) {return(NULL)}

      read.csv(infile$datapath, header = input$header,sep=",",col.names=c(str(input$cols)))
  }})
  output$data <- renderTable({contents()})
  output$man <- renderText({colm()})
  output$men <- renderText({head()})

})

UI.R

library(shiny)
shinyUI(fluidPage(

  titlePanel("The Ace!"),
           navbarPage("Calulus@Work",  
            tabPanel("About Tool",p("The tool designed for single place for Analytics.")),
            navbarMenu("Data Load",
            tabPanel("Delimter",
            sidebarLayout(
            sidebarPanel(fileInput('file1', 'Choose file to upload',
                                               accept = c('text/csv',
                                                 'text/comma-separated-values',
                                                 'text/tab-separated-values',
                                                 'text/plain','.csv','.tsv'
                                               )),
                                     tags$hr(),
                                     checkboxInput('header', 'Header', TRUE),
                                     textInput('cols',"Enter column names"),
                                     radioButtons('sep', 'Separator',c(Comma=',',Semicolon=';',
                                                    Tab='\t'),','),
                                     radioButtons('quote', 'Quote',
                                                  c(None='','Double Quote'='"','Single Quote'="'"),'"'),
                                     tags$hr(),
                                     ),
                                   mainPanel(
                                     tableOutput('contents')

textOutput("man"),
                                     textOutput("men")
                                   ))),
                        )                  
                         )#navbarPage

)#fluidpage
)#shinyUI

Error:
chr "\"a\",\"b\",\"x\""
Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  more columns than column names