0
votes

I've been trying to add a graph I made to my shiny layout but when I run the project it shows me this error.

I've got the following code for the serve.R:

library(shiny)
df <-read.csv('./CSV/data.csv')
shinyServer(function(input, output) {
  output$scatterPlot <- renderHighchart({
    hchart(df, "scatter", 
hcaes(x=df$revenue,y=df$users,group=df$name_group))
  })
})

And for the ui I got:

    library(shiny)
    library(shinydashboard)
    library(shinycssloaders)

    titlePanel("my_app")

    header <- dashboardHeader(title = "my_app" )

    sidebar <- dashboardSidebar(
      sidebarMenu(
        menuItem("Overview", tabName = "overview", icon = icon("book-open"))
    )
    body <- dashboardBody(
      tabItems(
        tabItem("overview",
                fluidRow(
                  box(
                    title = "revenue_vs_user", status = "primary",
                    withSpinner(highchartOutput("scatterPlot"))
                  ))
      )
    ))

    shinyUI(dashboardPage(header, sidebar, body, skin = "blue"))

All answers I've seen on this mistake say that it happens because the data is not being read correctly but in my enviroment variables the data appears, so it is being read. Thanks for the help!

1
My guess is that there's a difference in absolute/relative path when running it. Is there a warning immediately before it (perhaps on a shiny-server console or error log) that says Warning ... No such file or directory?r2evans
It doesn't show a warning or anything besides this mistakeMFTS
What is the directory structure on the shiny server? With an error like that, I've never seen it being read incorrectly, it's always due to path problems or arguments to the reading function (but your call to read.csv is not wrong).r2evans
the directory as a whole I've got root-> -CSV -PYfiles -RExamples -Rtool -.Rdata -.Rhistory -R Project - Readme inside the Rtool I have the project files where the ui.R and the server.R are located.MFTS

1 Answers

0
votes

I had the same problem. When developing the app and testing if the CSV would upload, R studio showed the CSV data properly uploaded and stored in the Environment variables. But when I would select Runn App, I would get the same error.

I also use a data sub-folder structure. I also setup an R Project in the folder above my app. So the folder structure looked like this:

./Project/app/data

where the Project file was in the Project folder, app.R file was in the app folder, and the CSV I was trying to upload was in the data folder.

I then tried putting the Project file in the app folder instead. I also updated the relative file path for read.csv in the app to reflect the new working directory. For some reasons this worked. I don't know why.