Download csv file to shinyApps.io

My application works fine locally, and I can successfully deploy my application on shinyapps.io server, but when I try to download the application in my browser using the shinyapps URL, I get the following error message: “Error object”, data “not found”. I think this is because the variable 'data' reads from the csv file in my local directory. Is there any way to upload this csv file to shinyapps server? I tried this but found nothing.

Here is the code that I use to read in files. I get the file from the same working directory as my server.R and ui.R. Thanks

server.R

library(shiny) college = read.csv("college.csv") 

ui.R (I added to this to find out if it fixes the problem, but it is not)

  library(shiny) college = read.csv("college.csv") 
+7
r shiny
source share
2 answers

Best practice would be to place your data in a folder, say ~/<application name>/data , and then call your data from your server.R to process your application directory ( /<application name>/ ) as the current working directory.

eg. I save my files as RDS objects in ~/ImputationApp/data/ and then read them with:

 foo.rds <- readRDS("data/foo.rds") 

Although what you are describing should do, double-check your file paths for the data files you are trying to load, and any wandering setwd() commands that might break the job. A common mistake is to put the full path to your data on your computer in server.R .

0
source share

I am currently facing a similar problem. Reading here and there, I realized that you can create a script called global.R in the same directory with ui.R and server.R . In this file (global.R) you can load libraries, in which case objects previously stored in the directory, for example, are called data. I created an object and saved it using saveRDS(df, "./data/df.RDS") . Then we loaded it from dir data with something like

 df <- readRDS("data/df.RDS") 

on global.R This works for me.

0
source share

All Articles