Unable to deploy to shinyapps.io

Hi R Community,
I have a shiny app script and a separate data cleaning script. I have a file which I am importing from my local environment (read_excel("C\..."). I guess that's why the app is not getting deployed in shinyapps.io. How can I change the file reference so that I can deploy it in shinyapps.io.

add a "www" folder to the project (if this doesn't exist already)
put the file into this folder
refer to this folder in your script
make sure to upload the folder together with your code

Then it should work!

Thanks for the response.
How can I add folder to the project? Is it using setwd. ?
And can I reger to the file/folder giving local system references?

No, you simply create a folder within your project's root folder like you will create a folder anywhere else in your system. This is not R specific.

It is not clear what you mean but you need to refer to the file using relative paths (relative to the project's root folder), not absolute paths.

The reasoning behind this is that when you deploy the app, the project root folder gets copied into the server along with the data inside it so by using file paths relative to the root folder, your code is able to access them both locally and in the server.

In my system, R by default has set "My Documents" as the working directory. So the data files I am using and the R scripts have been made in a folder in "My Documents". Hence, in the cleaning data R script, I have referred the file as below to import the excel file:
read_excel("Field_sup_test/EarlySpark_Baseline_2022_Field_supervisor_WIDE.xlsx")

Is this correct?

Yes, but this is the case when you are not in a project, you are supposed to create a project (which has its own root folder) for each shiny app you develop.

Here you can learn about project workflows

Thank you for your response. I have tried deploying the app after going through the resource. Now I have made a project for the shiny app I am using. The folder is having:

  1. R script used for cleaning data.
  2. Shiny app script.
  3. Data file (excel format)
    I have also the working directory the same as the project directory. I did not use setwd in the script. It was done in the console.
    The app does not deploy now also. Error is being shown. In the log I checked, one error was that the data frame is not found. But the data frame has been defined in the data cleaning script. I have attached the screenshot of the log page here below.

Without seen your code it is impossible to know what is wrong with it

But it's a large file. I am unable to figure out where the mistake is happening.

This topic was automatically closed 21 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.