简体   繁体   English

Shinyapps与服务器断开连接,可能超出了Excel文件的内存限制

[英]Shinyapps disconnecting from server, possibly exceeding memory limit with excel file

I created a shinyapp that displays output data from a 10,000-trial Monte Carlo simulation. 我创建了一个shinyapp ,用于显示10,000次试用的蒙特卡洛模拟的输出数据。 The simulation is of an entire football season with 238 teams, tracking seven variables for each team in each trial (16.66+ million data points). 该模拟模拟了整个238个足球赛季的情况,并在每次试验中跟踪了每个团队的七个变量(16.66+百万个数据点)。 The data from the simulation is stored in an excel file. 来自模拟的数据存储在excel文件中。

When I try to run the app from shinyapps.io , the ui.R loads just fine, including a small portion of the excel sheet (team names in a selectInput() command). 当我尝试从shinyapps.io运行应用程序时, ui.R加载得很好,包括一小部分excel工作表( selectInput()命令中的团队名称)。 The app always crashes before any of the server.R loads (all of my read_excel() commands are at the very beginning of my server.R . This, along with some other research I've done into other example of apps crashing unexpectedly, leads me to believe my excel file is too large for shiny to handle. I have each variable stored on a separate sheet in excel, with a different read_excel() command for each sheet. I was able to get a version of the app, storing only 2 of the 7 different tracking variables, to work fine when accessing the data from separate tabs. When I tried accessing all of the data from a single tab, the app crashes like before. 该应用程序始终在任何server.R加载之前崩溃(我的所有read_excel()命令都在我的server.R的最开始)。这与我对应用程序意外崩溃的其他示例所做的其他研究一起,使我相信我的Excel文件太大的shiny处理。我已经储存在一个单独的表在Excel中,用不同的每个变量read_excel()每个工作表命令。我能得到一个版本的应用程序,存储在7个不同的跟踪变量中,只有2个可以正常访问单独的标签中的数据,当我尝试从单个标签中访问所有数据时,应用程序像以前一样崩溃。

I have tried the advice from the shiny help pages in regards to changing the app advanced settings, instances, workers, etc. Nothing changed. 我尝试了shiny帮助页面中有关更改应用程序高级设置,实例,工作程序等的建议。没有任何更改。 I have checked my app logs: 我已经检查了我的应用日志:

2016-07-19T23:48:17.796234+00:00 shinyapps[115363]: 
2016-07-20T00:04:10.853831+00:00 shinyapps[115363]: Server version: 0.4.4.1986
2016-07-20T00:04:10.853884+00:00 shinyapps[115363]: R version: 3.3.1
2016-07-20T00:04:10.853895+00:00 shinyapps[115363]: shiny version: 0.13.2
2016-07-20T00:04:10.853906+00:00 shinyapps[115363]: rmarkdown version: NA
2016-07-20T00:04:10.853918+00:00 shinyapps[115363]: knitr version: NA
2016-07-20T00:04:10.853948+00:00 shinyapps[115363]: jsonlite version: 1.0
2016-07-20T00:04:10.853992+00:00 shinyapps[115363]: RJSONIO version: NA
2016-07-20T00:04:10.854026+00:00 shinyapps[115363]: htmltools version: 0.3.5
2016-07-20T00:04:11.030246+00:00 shinyapps[115363]: Using jsonlite for JSON processing
2016-07-20T00:04:11.034832+00:00 shinyapps[115363]: 
2016-07-20T00:04:11.034838+00:00 shinyapps[115363]: Starting R with process ID: '50'
2016-07-20T00:04:11.052472+00:00 shinyapps[115363]: 
2016-07-20T00:04:11.052477+00:00 shinyapps[115363]: Listening on http://0.0.0.0:50671
2016-07-20T00:04:11.119620+00:00 shinyapps[115363]: Loading required package: ggplot2
2016-07-20T00:04:11.341254+00:00 shinyapps[115363]: 
2016-07-20T00:04:11.341260+00:00 shinyapps[115363]: Attaching package: ‘plotly’
2016-07-20T00:04:11.341262+00:00 shinyapps[115363]: 
2016-07-20T00:04:11.341981+00:00 shinyapps[115363]: The following object is masked from ‘package:ggplot2’:
2016-07-20T00:04:11.341984+00:00 shinyapps[115363]: 
2016-07-20T00:04:11.341985+00:00 shinyapps[115363]:     last_plot
2016-07-20T00:04:11.341986+00:00 shinyapps[115363]: 
2016-07-20T00:04:11.342754+00:00 shinyapps[115363]: The following object is masked from ‘package:graphics’:
2016-07-20T00:04:11.342755+00:00 shinyapps[115363]: 
2016-07-20T00:04:11.342758+00:00 shinyapps[115363]: 
2016-07-20T00:04:11.342757+00:00 shinyapps[115363]:     layout
2016-07-20T03:20:09.766501+00:00 shinyapps[115363]: Server version: 0.4.4.1986
2016-07-20T03:20:09.766562+00:00 shinyapps[115363]: R version: 3.3.1
2016-07-20T03:20:09.766569+00:00 shinyapps[115363]: shiny version: 0.13.2
2016-07-20T03:20:09.766574+00:00 shinyapps[115363]: rmarkdown version: NA
2016-07-20T03:20:09.766575+00:00 shinyapps[115363]: knitr version: NA
2016-07-20T03:20:09.766575+00:00 shinyapps[115363]: jsonlite version: 1.0
2016-07-20T03:20:09.766603+00:00 shinyapps[115363]: RJSONIO version: NA
2016-07-20T03:20:09.766604+00:00 shinyapps[115363]: htmltools version: 0.3.5
2016-07-20T03:20:09.935430+00:00 shinyapps[115363]: Using jsonlite for JSON processing
2016-07-20T03:20:09.939423+00:00 shinyapps[115363]: 
2016-07-20T03:20:09.939429+00:00 shinyapps[115363]: Starting R with process ID: '17'
2016-07-20T03:20:09.955391+00:00 shinyapps[115363]: 
2016-07-20T03:20:09.955393+00:00 shinyapps[115363]: Listening on http://0.0.0.0:59412
2016-07-20T03:20:10.045463+00:00 shinyapps[115363]: Loading required package: ggplot2
2016-07-20T03:20:10.260363+00:00 shinyapps[115363]: 
2016-07-20T03:20:10.260369+00:00 shinyapps[115363]: Attaching package: ‘plotly’
2016-07-20T03:20:10.260372+00:00 shinyapps[115363]: 
2016-07-20T03:20:10.261097+00:00 shinyapps[115363]: The following object is masked from ‘package:ggplot2’:
2016-07-20T03:20:10.261100+00:00 shinyapps[115363]: 
2016-07-20T03:20:10.261101+00:00 shinyapps[115363]:     last_plot
2016-07-20T03:20:10.261834+00:00 shinyapps[115363]: The following object is masked from ‘package:graphics’:
2016-07-20T03:20:10.261836+00:00 shinyapps[115363]: 
2016-07-20T03:20:10.261839+00:00 shinyapps[115363]: 
2016-07-20T03:20:10.261838+00:00 shinyapps[115363]:     layout
2016-07-20T03:20:10.261102+00:00 shinyapps[115363]: 

I have changed my excel file so that all formulas and formatting is removed, and only values are stored, but the app is still crashing before running any of the server.R code. 我已经更改了我的excel文件,以便删除所有公式和格式,仅存储值,但是在运行任何server.R代码之前,该应用程序仍然崩溃。 I have tried saving the excel file as .csv files, but the file size is pretty much the same, and it would require a drastic change to my code to fully function, so I didn't pursue it much further. 我曾尝试将excel文件另存为.csv文件,但文件大小几乎相同,并且需要对我的代码进行彻底更改才能完全发挥作用,因此我没有做进一步的介绍。

I have seen some talk of using Google Sheet to write data from an app. 我曾经听说过有关使用Google表格从应用程序写入数据的讨论。 Would reading my data from Google Sheets be a better route to work around this issue? 从Google表格中读取我的数据是否可以解决此问题? Does anyone have any other solutions? 有人还有其他解决方案吗? Is reading my excel data even my problem? 读取我的excel数据甚至是我的问题吗?

A link to my app: https://loghan.shinyapps.io/Season_Projections/ 指向我的应用程序的链接: https : //loghan.shinyapps.io/Season_Projections/

You can try openxlsx package in R. You may find the package useful. 您可以在R中尝试openxlsx软件包。您可能会发现该软件包很有用。 As it reads data much much faster. 由于它读取数据的速度快得多。 It uses read.xlsx to read the excel file. 它使用read.xlsx读取excel文件。

You can use .csv files instead of .xls files. 您可以使用.csv文件而不是.xls文件。 Transitions between the two formats are easy in excel and R likes much more .csv files. 两种格式之间的转换在excel中很容易,R更喜欢.csv文件。 To read those .csv files use fread in data.table package. 要读取这些.csv文件,请使用data.table包中的fread。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM