Loading a database from a shiny app

I have a shiny app wich includes this code:

path <- "../data/taxy_base.csv"
fichero <- read.csv(path, header = TRUE, sep=";", quote = '"')

works OK when running from RStudio, but when I deploy it to shinyio, does not run: it appears the error message "Disconnected from the server."

What could it be?

Are you sure you are deploying the .csv file along with your app in the data folder?
Have you tryed with just this path?

path <- "data/taxy_base.csv"

To give us more information to work with, please post the content of your logs for that app from shinyapps.io

Thanks, I changed the path and deployed again, with the same result.

Here is the log:

Preparing to deploy application...Update application currently deployed at
https://joserondon.shinyapps.io/s_fichero_original/? [Y/n]
Uploading bundle for application: 1047167...DONE
Deploying bundle: 2270933 for application: 1047167 ...
Waiting for task: 633765386
building: Processing bundle: 2270933
building: Installing packages
building: Installing files
building: Pushing image: 2396712
deploying: Starting instances
rollforward: Activating new instances
terminating: Stopping old instances
Application successfully deployed to https://joserondon.shinyapps.io/s_fichero_original/

The .csv file is 100 Mb; is there a size restriction?


Two things:

  • All files for a Shiny app must be in the app's base folder on deployment or one of its sub-folders. Your path "../data/taxy_base.csv" would not work as it goes "up a folder" and thus outside the app folder. Move the file within the app directory and change the path accordingly.
  • If you have a large .cvs file, I suggest you convert it to RDS data (big compression) using the saveRDS and then readRDS in your app.

Hope this helps

1 Like

That is not the log, those are deployement messages, the logs for your app in shinyapps.io are located here

1 Like

Thanks a lot @pieterjanvc
RDS worked good as file passed from 108 Mb to 12. In fact, when running locally it loads by far faster the with .csv
I tryed path with "data..." , "/data..." and "../data..".
Only works with the last one. When starting locally goes well, after deployApp statement, does not work.

This is the log of the last run:

2019-07-28T21:08:14.429823+00:00 shinyapps[1047167]: by .GlobalEnv when processing object ‚Äėdataset_challenge‚Äô
2019-07-28T21:08:14.430326+00:00 shinyapps[1047167]: Attempting to load the environment ‚Äėpackage:stats‚Äô
2019-07-28T21:08:14.612666+00:00 shinyapps[1047167]: Server version: 1.7.6-6
2019-07-28T21:08:14.612682+00:00 shinyapps[1047167]: LANG: es_ES.UTF-8
2019-07-28T21:08:14.612683+00:00 shinyapps[1047167]: R version: 3.6.1
2019-07-28T21:08:14.612736+00:00 shinyapps[1047167]: jsonlite version: 1.6
2019-07-28T21:08:14.612748+00:00 shinyapps[1047167]: RJSONIO version: (none)
2019-07-28T21:08:14.612752+00:00 shinyapps[1047167]: htmltools version: 0.3.6
2019-07-28T21:08:14.612688+00:00 shinyapps[1047167]: shiny version: 1.3.2
2019-07-28T21:08:14.612709+00:00 shinyapps[1047167]: httpuv version: 1.5.1
2019-07-28T21:08:14.612714+00:00 shinyapps[1047167]: rmarkdown version: (none)
2019-07-28T21:08:14.612720+00:00 shinyapps[1047167]: knitr version: (none)
2019-07-28T21:08:14.612930+00:00 shinyapps[1047167]: Using pandoc at /opt/connect/ext/pandoc2
2019-07-28T21:08:14.764997+00:00 shinyapps[1047167]: Using jsonlite for JSON processing
2019-07-28T21:08:14.772659+00:00 shinyapps[1047167]:
2019-07-28T21:08:14.772661+00:00 shinyapps[1047167]: Starting R with process ID: '25'
2019-07-28T21:08:14.806445+00:00 shinyapps[1047167]:
2019-07-28T21:08:14.806447+00:00 shinyapps[1047167]: Listening on



Sorry @andresrcs This is the log:

2019-07-28T07:54:23.765283+00:00 shinyapps[1047167]: 62: file
2019-07-28T07:54:23.765286+00:00 shinyapps[1047167]: 61: read.table
2019-07-28T07:54:23.765287+00:00 shinyapps[1047167]: 60: read.csv
2019-07-28T07:54:23.765534+00:00 shinyapps[1047167]: Error in file(file, "rt") : no se puede abrir la conexión
2019-07-28T07:54:23.765289+00:00 shinyapps[1047167]: 59: server [/srv/connect/apps/s_fichero_original/app.r#30]
2019-07-28T07:55:57.739728+00:00 shinyapps[1047167]: Warning: namespace ‚Äėreshape‚Äô is not available and has been replaced
2019-07-28T07:55:57.739730+00:00 shinyapps[1047167]: by .GlobalEnv when processing object ‚Äėdataset_challenge‚Äô
2019-07-28T07:55:57.740257+00:00 shinyapps[1047167]: Attempting to load the environment ‚Äėpackage:stats‚Äô
2019-07-28T07:55:57.912012+00:00 shinyapps[1047167]: Server version: 1.7.6-6
2019-07-28T07:55:57.912014+00:00 shinyapps[1047167]: LANG: es_ES.UTF-8
2019-07-28T07:55:57.912031+00:00 shinyapps[1047167]: R version: 3.6.1
2019-07-28T07:55:57.912032+00:00 shinyapps[1047167]: shiny version: 1.3.2
2019-07-28T07:55:57.912063+00:00 shinyapps[1047167]: httpuv version: 1.5.1
2019-07-28T07:55:57.912064+00:00 shinyapps[1047167]: rmarkdown version: (none)
2019-07-28T07:55:57.912069+00:00 shinyapps[1047167]: knitr version: (none)
2019-07-28T07:55:57.912074+00:00 shinyapps[1047167]: jsonlite version: 1.6
2019-07-28T07:55:57.912111+00:00 shinyapps[1047167]: RJSONIO version: (none)
2019-07-28T07:55:57.912272+00:00 shinyapps[1047167]: Using pandoc at /opt/connect/ext/pandoc2
2019-07-28T07:55:57.912113+00:00 shinyapps[1047167]: htmltools version: 0.3.6
2019-07-28T07:55:58.111367+00:00 shinyapps[1047167]: Using jsonlite for JSON processing
2019-07-28T07:55:58.119887+00:00 shinyapps[1047167]:
2019-07-28T07:55:58.119889+00:00 shinyapps[1047167]: Starting R with process ID: '69'
2019-07-28T07:55:58.150349+00:00 shinyapps[1047167]:
2019-07-28T07:55:58.150351+00:00 shinyapps[1047167]: Listening on
2019-07-28T11:35:20.100531+00:00 shinyapps[1047167]: Warning: namespace ‚Äėreshape‚Äô is not available and has been replaced
2019-07-28T11:35:20.100534+00:00 shinyapps[1047167]: by .GlobalEnv when processing object ‚Äėdataset_challenge‚Äô
2019-07-28T11:35:20.101030+00:00 shinyapps[1047167]: Attempting to load the environment ‚Äėpackage:stats‚Äô
2019-07-28T11:35:20.344417+00:00 shinyapps[1047167]: Server version: 1.7.6-6
2019-07-28T11:35:20.344418+00:00 shinyapps[1047167]: LANG: es_ES.UTF-8
2019-07-28T11:35:20.344435+00:00 shinyapps[1047167]: R version: 3.6.1
2019-07-28T11:35:20.344436+00:00 shinyapps[1047167]: shiny version: 1.3.2
2019-07-28T11:35:20.344436+00:00 shinyapps[1047167]: httpuv version: 1.5.1
2019-07-28T11:35:20.344437+00:00 shinyapps[1047167]: rmarkdown version: (none)
2019-07-28T11:35:20.344465+00:00 shinyapps[1047167]: knitr version: (none)
2019-07-28T11:35:20.344471+00:00 shinyapps[1047167]: jsonlite version: 1.6
2019-07-28T11:35:20.344472+00:00 shinyapps[1047167]: RJSONIO version: (none)
2019-07-28T11:35:20.344481+00:00 shinyapps[1047167]: htmltools version: 0.3.6
2019-07-28T11:35:20.344669+00:00 shinyapps[1047167]: Using pandoc at /opt/connect/ext/pandoc2
2019-07-28T11:35:20.574906+00:00 shinyapps[1047167]: Using jsonlite for JSON processing
2019-07-28T11:35:20.583389+00:00 shinyapps[1047167]:
2019-07-28T11:35:20.583397+00:00 shinyapps[1047167]: Starting R with process ID: '24'
2019-07-28T11:35:20.637489+00:00 shinyapps[1047167]:
2019-07-28T11:35:20.637497+00:00 shinyapps[1047167]: Listening on
2019-07-28T11:35:23.859562+00:00 shinyapps[1047167]: Warning in file(file, "rt") :
2019-07-28T11:35:23.859563+00:00 shinyapps[1047167]: no fue posible abrir el archivo 'data/taxy_base.csv': No such file or directory
2019-07-28T11:35:23.860334+00:00 shinyapps[1047167]: Warning: Error in file: no se puede abrir la conexión
2019-07-28T11:35:23.881127+00:00 shinyapps[1047167]: 62: file
2019-07-28T11:35:23.881129+00:00 shinyapps[1047167]: 61: read.table
2019-07-28T11:35:23.881130+00:00 shinyapps[1047167]: 60: read.csv
2019-07-28T11:35:23.881131+00:00 shinyapps[1047167]: 59: server [/srv/connect/apps/s_fichero_original/app.r#30]
2019-07-28T11:35:23.881288+00:00 shinyapps[1047167]: Error in file(file, "rt") : no se puede abrir la conexión




You see, one of the errors is that the data is not found. Did you move the data ?? Changing the directory is only going to work if you also move the data to the correct location, meaning in the Shiny folder (the folder where your app.R resides).

SO ... if the dataset is in the same folder as the app.R, then you call it by read.csv("taxy_base.csv") or rds if you're using that. If you put the data in a subfolder (meaning a folder within the Shiny app folder, for example data, then you call it: read.csv("data/taxy_base.csv")


This suggests that your csv file is not being deployed to shinyapps.io and doesn't exist in the especified folder on the server.

Actually there is a 100MB limit so maybe you are over passing it.

Thanks a lot @pieterjanvc!
Now it works:
Still working in formats and calculations.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.