Reputation: 1053
I tried to deploy my Shiny apps to xxx.shinyapps.io, but the problem is I use own dataset. I set my dataset to my directory, but when I try to deploy it I got error:
Listening on http://127.0.0.1:45220 Loading required package: DBIError in setwd("C:/Users/xxx/Dropbox/shiny/archive/db") : cannot change working directory
Upvotes: 2
Views: 5529
Reputation: 992
There are two ways
Open a ".R"(navin.R e.g.) file in the app directory( where ui.r and server.R is placed) where you make the R object which contains the data (For example: dataS <- read.csv("XX.csv"); dataT <- read.csv("YY.csv"))
and then in server.R , write the code initially: source(navin.R) And use dataS, dataT objects as usual.
Place XX.csv and YY..csv in the same directory ( or any directory but then give the "relative path" ) and do everything as usual
For example : I used local data to make shiny Apps https://manaswink.shinyapps.io/TelecomTower/
Upvotes: 1
Reputation: 1
Adding to the comments provided by Paul
ui.R
and server.R
runApp()
shinyapps.io
Sample code:
For -> ui.R - where 'county.csv is local dataset'
county1<-read.csv("Data/county.csv")
library(shiny)
shinyUI(pageWithSidebar(..
..........
.......
Similarly,
For -> server.R
county1<-read.csv("Data/county.csv")
shinyServer(function(input, output, session) {....
......
......
Upvotes: 0
Reputation: 992
In server.R , have this code at the top
source("datarep.R)
Make a new .R file "datarep.R " in the same directory. That file has just one code
data <- read.csv("data.csv")
Upvotes: 2
Reputation: 12664
Put your dataset in a subdirectory of your shiny app directory (and change you code accordingly). Be sure to make the path to the data a relative path (not an absolute path - this generates a warning). This has worked well for me.
Upvotes: 9