R shiny deploying " No such file in path"

keep receiving the error "paths should be to files within project directory".

,
it works locally but i get this error and then when it goes away, I get the same error when trying to publish. Is it a problem where my data is located?


library(shiny)
library(ggplot2)


spin_rate<-read.csv("C:/Users/Documents/App1Final/final/ tracker final.csv", dec=".", header=TRUE)

If you are going to deploy your app on a system other than yours then you can't use absolute paths (to a local file), you have to use file paths relative to the app's root folder.

@andresrcs can you provide an example how to do that?

how would the above absolute path be converted to a relative file, I tried different variations but none seemed to work

Assuming your app files (app.R or ui.R +server.R) are located on the "App1Final" folder you could use something like this

spin_rate<-read.csv("final/tracker final.csv", dec=".", header=TRUE)

@andresrcs I am still receiving the same error, "cannot open the connection" it is a single final shiny app, and the data is in there as well

I moved the folders now and it is located in folder2

spin_rate<-read.csv("folder2/tracker final.csv", dec=".", header=TRUE)

Could you show us your actual file structure? I'm just guessing what your working directory actually is, I suppose I'm guessing wrong since you keep getting that error message.

So I was able to get past that error, but now I am encountering anew one after launching the app. I get the cannot change working directory error after the app is successfully launched

setwd("~/Questionaire")
library(shiny)
library(ggplot2)


spin<-read.csv("./pitch tracker.csv", dec=".", header=TRUE)

https://aeb620109.shinyapps.io/questionaire/

is the link to the error, any experience with this? Thank you for your help

@andresrcs

You shouldn't change working directory for a shiny app (and you don't need to), the app uses the root directory as the working directory, just delete that command.
As a side note, when working with RStudio projects, changing the working directory is considered a bad practice.

Thank you, if i still get the same error, I restarted the program and still received the error.

"Loading required package: shiny
Want to understand how all the pieces fit together? See the R for Data Science book:


Warning in file(file, "rt") :
cannot open file './pitch tracker.csv': No such file or directory
Error in file(file, "rt") : cannot open the connection"

Again, please show your actual file structure, I have no way to know where your files are relative to each other,so I can't give you any specific solution.

I don't understand how this is related to your issue, could you explain? BTW I already read that book.

I have a directory named Questionaire in my documents, and when i open R, the working directory is C:/Users/my name/Documents" so I am unsure what file structure you need me to supply, will happily give you the information. Thank you for your help sofar

If you are working on a shiny app then you should be working on a "project" and the working directory would automatically get changed to the root folder for the app
Take a look into this book (in progress) to understand the basic workflow when working with shiny apps

Thank you for your help, Cheers!