R 闪亮,从情节中获取细节
我已经开发了一个应用程序,我正在生成绘图。我能够渲染绘图并下载它,没有任何问题 当我将光标移动到点上时,我希望获得图形中点的详细信息。通过搜索,我不确定是否可以在Shiny中获得此信息 任何帮助都会很好 下面是我用过的代码 用户界面代码:R 闪亮,从情节中获取细节,r,shiny,R,Shiny,我已经开发了一个应用程序,我正在生成绘图。我能够渲染绘图并下载它,没有任何问题 当我将光标移动到点上时,我希望获得图形中点的详细信息。通过搜索,我不确定是否可以在Shiny中获得此信息 任何帮助都会很好 下面是我用过的代码 用户界面代码: tabItem(tabName = "models2", fluidPage( fluidRow( infoBoxOutput("overview") ), f
tabItem(tabName = "models2",
fluidPage(
fluidRow(
infoBoxOutput("overview")
),
fluidRow(
actionButton("result1","Generate Result"),
downloadButton('downloadPlot','Download Plot'),
plotOutput("plot3")
)
))
服务器代码
server <- function(input,output){
output$claim_overview <- renderValueBox({
valueBox(
paste("91")," Overview",icon=icon("hourglass"),
color="green"
)
})
data<- reactiveValues()
observeEvent(input$result1,{
data$plot <- ggplot(data=timedata, aes(x=dat1, y=yes, group=3))+
geom_point(shape=1)+
coord_cartesian(xlim=c(dat1_xlowlim,dat1_xhighlim))+
labs(title="Prediction Probability",x="Reg.Date",y="True probability")
})
output$plot3 <- renderPlot({ data$plot })
output$downloadPlot <- downloadHandler(
filename = function()
{paste("input$plot3",'.png',sep='')
},
content = function(file){
ggsave(file,plot = data$plot)
}
)
}
server您可以使用画笔
选项或悬停
选项从绘图中获取任何信息。
鼠标悬停示例:
df<- table(rpois(100, 5))
ui <- fluidPage(
mainPanel(
plotOutput(outputId = "scatterplot", hover = "plot_hover"),
verbatimTextOutput(outputId = "dftable"),
br()
)
)
server <- function(input, output) {
output$scatterplot <- renderPlot({
plot(df, type = "h", col = "red", lwd = 10)
})
output$dftable <- renderPrint({
paste(input$plot_hover)
})
}
shinyApp(ui = ui, server = server)
df