Having error in uploading file : error 'arg' should be one of “link”, “response”, “terms”


iitModel <- readRDS("model_iit.rds")
iit_model <- read.csv("training.csv")

# Define UI for application that draws a histogram
ui <- fluidPage(
  # Application title
  titlePanel("IIT Dataset Predictions"),
  # Sidebar with a slider input for number of bins 
      # Input: Select a file ----
      fileInput("file1", "upload csv file here",
                multiple = FALSE,
                accept = c("text/csv",
      # Button
      downloadButton("downloadData", "Download the Predictions")
    # Show the table with the predictions

# Define server logic required to draw a histogram
server <- function(input, output) {
    df <- read.csv(input$file1$datapath, stringsAsFactors = TRUE)
    df$predictions<-predict(iitModel, newdata = iit, type ="class")
  output$mytable = DT::renderDataTable({
    return(DT::datatable(reactiveDF(),  options = list(pageLength = 100), filter = c("top")))
  # Downloadable csv of selected dataset ----
  output$downloadData <- downloadHandler(
    filename = function() {
      paste("data-", Sys.Date(), ".csv", sep="")
    content = function(file) {
      write.csv(reactiveDF(), file, row.names = FALSE)

# Run the application 
shinyApp(ui = ui, server = server)

Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

sex Age Weight administered_days administer_status gestation_period
F 0.581 1.1446 1.8449682 1 0.160429207
F 0.679 0.7772 0.4836813 1 0.157766427
M 1.572 2.1617 0.4836813 1 0.157766427
M 0.201 0.318 2.6211847 0 0.147115304
F 0.495 2.1617 1.8449682 1 0.157766427
F 0.777 0.4166 0.4836813 1 0.160429207
F 1.572 1.4201 1.8449682 1 2.704722831
M 0.201 1.3351 1.4827338 0 0.160429207

This is 20% test data. I also scaled the numeric variables. Administer_status is a categorical variable (yes=1, No=0)
Any help on this will be highly appreciated.

Best practices for shiny reprexes, is available here:

This will make it easier for folks to replicate your issue and offer suggestions to solve it.

I have solved the problem. The error was attributed to my response variable used in the model building . I was using class in the shiny as against response used in the logistic regression model. That has now been corrected and my shiny is running very well with the required output.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.