13

My app runs fine locally and I am able to successfully deploy my app to the shinyapps.io server, but I get the following error message when I try and load the app in my browser using the shinyapps URL: "Error object 'data' not found.' I think this is because the 'data' variable reads from a csv file on my local directory. Is there a way I can upload this csv file to the shinyapps server? I've tried looking this up but I've found nothing.

Here's the code I am using to read in the files. I'm getting 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 see if it fixes the problem, but it doesn't)

 library(shiny) college = read.csv("college.csv") 
6
  • Are you sure your csv file is located in the app directory? Before uploading the app I mean. Commented Oct 11, 2014 at 15:48
  • Yes it's in the app folder. I'm really perplexed as to why it doesn't upload to the server. Commented Oct 12, 2014 at 2:59
  • I have no problem loading csv file in shiny. Could you post your code where you are loading csv file? Commented Oct 12, 2014 at 7:18
  • Could it be that you do something wrong with how you define the path to the csv? Commented Oct 12, 2014 at 9:50
  • I've gone ahead and added the code to show how I'm reading in the csv file. It's in the same directory as my shiny files, but it doesn't get uploaded to the shinyapps server for some reason. Commented Oct 12, 2014 at 15:38

3 Answers 3

1

Currently I was facing a similar trouble. Reading here and there, I realized that you can create a script called global.R in the same dir with ui.R and server.R. On this file (global.R) you can load libraries and, in this case, objects previously saved on a dir, for example, called data. I created the object and the saved it with saveRDS(df, "./data/df.RDS"). Then loaded it from the data dir with something like

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

on the global.R That works for me.

Sign up to request clarification or add additional context in comments.

Comments

0

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

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

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

Even though what you describe should run, double check your filepaths for the datafiles you are trying to load and any stray setwd() commands that could be mucking up the works. A common misstep is to put the fully qualified path to your data on your machine in your server.R.

1 Comment

@Kamal did this resolve your issue or are you still having trouble?
0

I know it's too late but I believe creating a folder named www in your directory and placing the csv there should solve the problem.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.