【发布时间】:2018-10-03 07:34:10
【问题描述】:
我正在使用 Shiny 开发应用程序。在 Shiny 中,我正在使用操作按钮渲染一个简单的绘图。我已经包含一个下载按钮来下载现在在 UI 中的图。来自我的代码(plot3)
我尝试了以下代码来保存图像,但出现错误
plotInput 未找到。
谁能建议我哪里出错了。
以下是我的代码供参考。 用户界面:
ui <- tabItem(tabName = "models2",
fluidPage(
fluidRow(
infoBoxOutput("overview")
),
fluidRow(
actionButton("result1","Generate Result"),
downloadButton('downloadPlot','Download Plot'),
plotOutput("plot3")
)
))
服务器
server <- function(input,output,session{
output$overview <- renderValueBox({
valueBox(
paste("91"),"Overview",icon=icon("hourglass"),
color="green"
)
})
observeEvent(input$result1,{
output$plot3 <- renderPlot({
ggplot(data=timedata, aes(x=dat1, y=yes, group=3))+
geom_point(shape=1)+
coord_cartesian(xlim=c(dat1_xlowlim,dat1_xhighlim))+
labs(title="Probability",x="Date",y="True probability")
})
})
output$downloadPlot <- downloadHandler(
filename = function(){paste(input$plot3,'.png',sep='')},
content = function(plot3){
ggsave(plot3,plotInput())
}
)
})
另外,要注意我的闪亮和 R 工作室是在 R 环境中。
【问题讨论】:
-
实验室中的错字(title="Probability",x="Date",y="真实概率")
-
@A.Suliman 我现在将纠正它。虽然我得到了情节,但问题是我无法下载情节
-
首先,服务器函数的参数后面有右括号。然后你会得到
Warning: Error in plotInput: could not find function "plotInput"。