Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (19k points)

This is my code in shiny R

ui.R:

fileInput("f1", 

                  "Load Input File", 

                  accept = c("text/csv", "text/comma-separated-values,text/plain",".csv")

        )

server.R:

execute = observeEvent(input$runButton, {

    output$plot1 = renderPlot({

        inFile = input$file1

        if (is.null(inFile)) {

            print(NULL)

        }

        podr_fun_graphs(inFile$datapath)

    })

}

podr_graphs function:

podr_fun_graphs <- function(p) {

    df1 <- read.delim(p, sep = "\t")

}

and I end up with the following error:

Warning: Error in read.table: 'file' must be a character string or connection

1 Answer

0 votes
by (33.1k points)

Your if statement in the server.R is wrong. It should be like this:

if (is.null(inFile)) {

     return(NULL)

   }

Hope this answer helps you!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...