对用户上传的文件进行统计测试

问题描述

我目前正在尝试开发一个应用程序,可以对用户上传的任何文件进行统计测试。问题是我在尝试进行测试时经常遇到问题,并且出现许多“错误”消息。例如,在这里我无法进行 t 检验。 请您在我的代码中查找错误,因为我自己似乎无法找到它们。此外,如果您有任何其他可能与我正在尝试创建的应用程序类似的代码建议,我很乐意看到它们获得一些灵感并更好地了解 Shiny 的工作原理。 这是我的代码的开头, 非常感谢您的关注。

library(ggplot2)
library(desctable)
ui <- fluidPage(
  tabPanel(
    "Upload File",titlePanel("Uploading Files"),sidebarLayout(
      sidebarPanel(
        fileInput('file1','Choose CSV File',min=0,max=1000,value=500
                  accept=c('.csv')),checkBoxInput('header','Header',TRUE),radioButtons('sep','Separator',choices = c(Comma=',',Semicolon=';',Tab='\t'),selected = ','),selectInput('xcol','X Variable',"",selected = NULL),selectInput('ycol','Y Variable',selectInput("method","Select t test type",c("One-sample t test","Independent two-sample t test"
                    ),),mainPanel(
         
          plotOutput('MyPlot'),tableOutput("table"),verbatimtextoutput("summary")
        )
      )
    )
  )
  
  server <- function(input,output,session)
  {
    output$table<- renderDataTable(input$file1)
    
    myfiles <- reactive({
      req(input$file1$datapath,file.exists(input$file1$datapath))
      
read.csv(input$file1$datapath)
    })
output$summary<-renderPrint(myfiles%>%desctable(stars=list((“N”  =length,“Moyenne”= is.normal~mean,“Médiane”=median,“MAD”=mad))    
  observeEvent(myfiles(),{
      req(myfiles())
      nms <- colnames(myfiles())
      updateSelectInput(
        session,inputId = 'xcol',label = 'X Variable',choices = nms,selected = nms[1]
      )
      
      updateSelectInput(
        session,inputId = 'ycol',label = 'Y Variable',selected = nms[1]
      )
    })
    
    output$table <- renderTable({
      if(is.null(dff())){return ()}
      
      if(input$method == "One-sample t test"){
        t.test(myfiles[input$xcol],mu = as.numeric(input$mu))
        
       else if (input$method == "Independent two-sample t test"){
        t.test(input$xcol ~ input$ycol,data = myfiles)}
        
        output$MyPlot <- renderPlot({
          req(myfiles(),input$xcol,input$ycol)
          ggplot(data = myfiles(),mapping = aes_string(input$xcol,input$ycol)) +
            geom_point() +theme_dark()
           
        })}
      
      
      shinyApp(ui,server)```

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)