gpt4 book ai didi

r - 如何在 R 中使用 plotly

转载 作者:行者123 更新时间:2023-12-04 14:31:17 25 4
gpt4 key购买 nike

我正在尝试为我使用 Shiny 生成的输出添加图形。我在生成图形时出错。有人可以看看并提供帮助。条形图参数是根据计算生成的基于计算的输出。

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"),

最佳答案

首先,对你的帖子有两点评论:

  • 它不可重现,请参阅 here了解什么是可重现的示例以及如何制作一个
  • 显然你搜索的还不够多。在任何搜索引擎中输入“r Shiny plotly output”都会给出几个潜在的解决方案(例如 here)。

  • 下次遇到问题,请考虑这两点,然后再在 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)

    关于r - 如何在 R 中使用 plotly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60294046/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com