Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to deploy shiny app that uses local data

I'm deploying my shiny app and I don't know how to input my a local dataset. I keep getting Error: object "data" not found. Here is my path to shiny folder.

library(shinyapps)
shinyapps::deployApp('C:\\Users\\Jeremy\\Desktop\\jerm2')

In this directory (jerm2), I have 3 things: ui.R, server.R, and my local dataset, a .csv called proj.csv.

In the server.R file, I set data<-read.csv("proj.csv")

I just don't know how to get Shiny to pick up my datasets.

like image 706
Tyrion Lannister Avatar asked Jan 06 '15 06:01

Tyrion Lannister


People also ask

Can you run Shiny app locally?

You might be eager to deploy your Shiny app to a remote server. But the simplest way to run a Shiny app is to run it locally. You only need the shiny R package installed, and you can run the app in your browser.

How do you load data on the Shiny app?

Your title asks about importing a data frame into shiny. That can be done by storing the data frame either as a binary file using the save() function or a csv file using write. csv() and having the shiny app read it in using load() for a binary file or read. csv() for a csv file.

Why does my app work locally but not on my Shiny server?

Your application may be dependent on packages that are installed and loaded in your environment, but aren't installed for the correct user on the Shiny Server. Make sure that all necessary packages are installed for the same user set under run_as in your Shiny Server configuration file.


1 Answers

You may want to add a subdirectory in your shiny folder called "Data" and put proj.csv there.

Then, in your server.r put:

data<-read.csv("./Data/proj.csv")

That will make it clear where the data is when the app is deployed to the ShinyApps service.

like image 58
John Paul Avatar answered Oct 11 '22 22:10

John Paul