本文主要是介绍解决 R shiny的 plotOutput() renderPlot() 在shiny app界面没有显示图片的问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
遇到的问题
shiny新手,在shiny app查看生成的图片时,找不到我的图在哪。(牛爷爷:我的图图呢.jpg)
传入的数据没有任何问题,新开了一个test.R测试,能在plot窗口看见图:
而shiny的ui、server代码我也自认为没有语法问题,因为同app的另一个tab能生成图片:
百思不得其解,在网上搜了一下都找不到类似的问题,很愁。
br()
解决方法
纯属灵光乍现,显示不出图片的renderplot代码如下:
if(normalizaiton_title_name == "Not normalized"){plotSampleDistributions(proteus_prodat, title=normalizaiton_title_name, fill="condition", method="violin")}
if(normalizaiton_title_name == "Median normalization"){plotSampleDistributions(proteus_prodat.med, title=normalizaiton_title_name, fill="condition", method="violin")}
if(normalizaiton_title_name == "Quantile normalization"){plotSampleDistributions(proteus_prodat.quant, title=normalizaiton_title_name, fill="condition", method="violin")}
能显示出图片的renderplot代码如下:
getPlot(inputdf(), flag = 'qc', selector = input$default_method_qc_input)
getPlot
是我自己写的另一个R脚本,用于生成图。
我就在想会不会是因为getPlot()调用完会有个return
?(虽然我没写return,里面也是if的判断
于是我给显示不出图片的renderplot代码加了3个return
:
if(normalizaiton_title_name == "Not normalized"){return(plotSampleDistributions(proteus_prodat, title=normalizaiton_title_name, fill="condition", method="violin"))}if(normalizaiton_title_name == "Median normalization"){return(plotSampleDistributions(proteus_prodat.med, title=normalizaiton_title_name, fill="condition", method="violin"))}if(normalizaiton_title_name == "Quantile normalization"){return(plotSampleDistributions(proteus_prodat.quant, title=normalizaiton_title_name, fill="condition", method="violin"))}
我的图图终于出来了!!!!✿✿ヽ(°▽°)ノ✿
打个广告
文章最后给自己打个广告,点我传送到Github项目(在写了在写了)。
这篇关于解决 R shiny的 plotOutput() renderPlot() 在shiny app界面没有显示图片的问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!