我试图在Rshiny中重新排列y数据帧的列。然而,这些都不起作用

我试图在Rshiny中重新排列y数据帧的列。然而,这些都不起作用,r,R,我有一个名为status的输入变量,它应该是数据帧的第一列。我已经尝试了下面给出的所有选项,但我总是在shiny中出错 library(shiny) ui<-fluidPage( titlePanel("My Hello World Shiny Example!"), sidebarLayout( sidebarPanel( fileInput(inputId="data",label="Choose CSV file",multiple=FALSE,accept=c(

我有一个名为status的输入变量,它应该是数据帧的第一列。我已经尝试了下面给出的所有选项,但我总是在shiny中出错

library(shiny)
ui<-fluidPage(
  titlePanel("My Hello World Shiny Example!"),
  sidebarLayout(
  sidebarPanel(
    fileInput(inputId="data",label="Choose CSV file",multiple=FALSE,accept=c("text/csv","text/comma-seperated-values,text/plain",".csv"),width=NULL,buttonLabel="Browse",placeholder="No file selected"),
checkboxInput(inputId="header",label="Header",value=FALSE),
                                                   radioButtons(inputId = 'sep', label = 'Separator', 
                                                                choices = c(Comma=',',Semicolon=';',Tab='\t', Space=''), selected = ','),
uiOutput("status1")
    ),
  mainPanel(
    uiOutput("dataframe")
  )
  )
)
server<-function(input,output){
  file<-reactive({
    x<-input$data
    if(is.null(x)){return()}
    read.table(file=x$datapath,sep=input$sep,header=input$header)
  })
  output$status1<-renderUI({
    selectInput("status","Select Dependent variable",choices=names(file()),multiple=FALSE)
  })
  y1<-reactive({

  #data.frame(cbind(file()[,input$status],file()[,-paste0(input$status)]))
错误消息是一元运算符的无效参数

#data.frame(cbind(file()[,input$status],subset(file(),select= -file()[,input$status])))
      # vari<-setdiff(names(file()),input$status)
      # data.frame(cbind(file()[,c(input$status,vari)]))
错误消息是x应该是两个以上的维度

      #y<-file()
      # var<-setdiff(names(y),input$status)
      # data.frame(cbind(y[c(input$status,var)]))
#data.frame(cbind(y[,c(input$status,c(setdiff(names(y),input$status)))]))
})
  output$x1<-renderTable({
    if(is.null(file())){return()}
    file()
  })
  output$dataframe<-renderUI({
    tableOutput("x1")
  })
}
shinyApp(ui=ui,server=server)
})

输出$x1欢迎使用SO。请提供一个可复制的示例。这将给那些想要帮助你的人提供一些工作和测试的机会。你可以看看。谢谢你的评论。我已经添加了运行应用程序所需的代码。错误消息之间的代码片段是我尝试生成数据帧的各种方式