0

I have one input variable called status and this should be the first column of my dataframe. I have tried all the options given below but I always get an error in 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)]))

Error message is invalid argument to unary operator

#data.frame(cbind(file()[,input$status],subset(file(),select= -file()[,input$status])))

Error message is invalid argument to unary operator

      # vari<-setdiff(names(file()),input$status)
      # data.frame(cbind(file()[,c(input$status,vari)]))

Error message is x should be more than two dimensions

      #y<-file()
      # var<-setdiff(names(y),input$status)
      # data.frame(cbind(y[c(input$status,var)]))

Error message is x should be more than two dimensions

#data.frame(cbind(y[,c(input$status,c(setdiff(names(y),input$status)))]))

Error message is x should be more than two dimensions

})
  output$x1<-renderTable({
    if(is.null(file())){return()}
    file()
  })
  output$dataframe<-renderUI({
    tableOutput("x1")
  })
}
shinyApp(ui=ui,server=server)
Sameera G
  • 21
  • 2
  • Welcome to SO. Please provide a reproducible example. This will give people who want to help you something to work with and to test. You can read about it **[here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)**. – KoenV Jul 11 '18 at 09:19
  • Thank you for the comment. I have the added the code required to run the app. The snippets of code between error messages are various ways I tried to generate the dataframe – Sameera G Jul 12 '18 at 14:30

0 Answers0