如何解决渲染存储在R Shiny应用程序列表中的多个图
我想通过闪亮的应用程序渲染存储在“情节列表”中的条形图。我是Shiny的新手,因此需要帮助。代码:
o<-list()
for(i in 1:10){
Z3<-seq(1+i,10+i,1)
o<-append(o,list(Z3))
}
Plotlist <- vector(mode = "list",10)
for(i in 1:10){
s<-barplot(o[[i]],names.arg = paste("A",1:10,sep = "_"),main=paste("Plot",i))
Plotlist[[i]]<-recordPlot()
}
library(shiny)
ui<-fluidPage(titlePanel("Plots in a list"),sidebarPanel(selectInput("plot","Choose Plot:",choices=paste("Plot",1:10)),hr(),helpText("Trial Plots"),mainPanel(plotOutput("BARPLOT"))))
server<-function(input,output) {
output$BARPLOT<-renderPlot(for(i in 1:10){Plotlist[[i]]})
}
shinyApp(ui,server)
解决方法
找到了解决方案,谢谢Abdessabour Mtk
choices = 1:10
names(choices) <- paste("Plot",1:10)
shinyApp(
ui = fluidPage(
titlePanel("Plots in a list"),sidebarPanel(
selectInput("plot","Choose plot:",choices=choices),hr(),helpText("Trail plots")),plotOutput("barplot")
),server = function(input,output) {
output$barplot<-renderPlot({
i<- as.integer(input$plot)
Plotlist[[i]]
})
}
)
,
要打印指定的图,您需要访问<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://raw.githubusercontent.com/okfocus/okzoom/master/src/okzoom.min.js"></script>
<div>
<img src="https://i.imgur.com/eulKI.jpg">
</div>
内的selectinput
的选定值,方法是添加renderplot
,其中plot是输入的名称
{i<-input$plot}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。