我正在尝试为使用闪亮生成的输出添加图形。我在生成图形时出错。有人可以看看和协助吗?条形图参数是通过计算生成的基于计算的输出。
server
output$graph<- renderPlotly({
plotly( x= c(as.numeric(input$contract), round(frateperton()), differencerate()),
y= c('Contract Rate', 'ZBC Rate', 'Difference'),
name = "Zero Based Rate Chart",
type = "bar")
})
UI
plotlyOutput("graph"),
首先,在您的帖子上有两句话:
下次您遇到问题时,请在StackOverflow上发表文章之前考虑这两点。
现在,这是答案(使用iris
数据,因为您的示例不可复制):
library(shiny)
library(plotly)
ui <- fluidPage(
selectInput("choice", "Choose", choices = names(iris), selected = NULL),
plotlyOutput("graph")
)
server <- function(input, output, session){
output$graph <- renderPlotly({
plot_ly(iris, x = ~get(input$choice), y = ~Sepal.Length, type = 'scatter', mode = 'markers')
})
}
shinyApp(ui, server)