[英]error and warning messages in R console and blank downloaded plot in shiny app
i am fairly new to shiny. 我是新来的闪亮。 i am trying to build ui that has drop downs (and plots/data display) that are conditional on an initial selection field.
我正在尝试构建具有以初始选择字段为条件的下拉列表(和图表/数据显示)的ui。 i have made a simplified example using the USArrests data set...
我使用USArrests数据集做了一个简化的示例...
https://gist.github.com/gjabel/4059ae889dea4b8ca0ca https://gist.github.com/gjabel/4059ae889dea4b8ca0ca
or 要么
shiny::runGist('4059ae889dea4b8ca0ca') 闪亮:: runGist( '4059ae889dea4b8ca0ca')
i have a couple of things that i can not figure out. 我有几件事我不知道。
1) i get error messages in the R console relating to the default plot (and subsequent plots). 1)我在R控制台中收到与默认图(及后续图)有关的错误消息。
Warning in min(x) : no non-missing arguments to min; returning Inf
2) i get error messages in the R console relating to the data... 2)我在R控制台中收到与数据有关的错误消息...
Warning in matrix(align.tmp[(2 - pos):(ncol(x) + 1)], nrow = nrow(x), ncol = ncol(x) + :
data length exceeds size of matrix
3) the download plot button returns a blank plot 3)下载图按钮返回空白图
4) when i select all from the first drop down i get no plot. 4)当我从第一个下拉列表中选择全部时,我没有图。 (i guess this is related to 1)?)
(我想这与1相关)?)
any ideas how to solve any of these (i think they might all be related)? 任何想法如何解决这些问题(我认为它们可能都相关)?
1 +2) Check the Shiny processing model: http://rstudio.github.io/shiny/tutorial/#execution-scheduling 1 +2)检查Shiny处理模型: http : //rstudio.github.io/shiny/tutorial/#execution-scheduling
Simplest solution for your case is to check if df2 is already filled with data: 针对您的情况,最简单的解决方案是检查df2是否已填充数据:
getplot <- reactive({
if(!is.null(input$crime)) {
df2<-getdf()$df2
if(dim(df2)[1] != 0){
...
}
and there will be no more errors / warnings. 不会再有错误/警告。
3) as far as I know you are not allowed to call a reactive function in there! 3)据我所知,您不允许在其中调用反应函数! Copy all your code from getplot into content= ... and it should be working.
将所有代码从getplot复制到content = ...,它应该可以正常工作。
And add a "contentType = 'image/png'" to take care that a png file will be created. 并添加“ contentType ='image / png'”,以确保将创建png文件。
4) you are trying to plot numerical and factorial data? 4)您正在尝试绘制数值和阶乘数据? I expect something like this
我期望这样的事情
plot(df2[,1:4])
will be the solution. 将是解决方案。
In general: You should get familiar to data frames. 通常:您应该熟悉数据框架。 Your data perfectly fits into a data frame and not a list.
您的数据完全适合数据框而不是列表。 This will fix several conversion problems
这将解决几个转换问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.