Rshiny 无法输出 ggstatsplot

互联网 行业动态 更新时间:2024-06-13 00:17:29

ste*_*fan 5

.data代词仅在用于动词dplyr内部或例如 inside时才有效ggplot2::aes()。但是,在您的情况下,ggbetweenstats需要一个不带引号的列名并作为错误消息

ensym 错误:无法转换为符号。

建议,通过rlang::ensym.

因此,要修复您的代码,您必须传递一个 例如可以通过symbol以下方式实现的代码:ggbetweenstats!!rlang::sym(input$Weekday)

library(ggstatsplot)
library(shiny)

ui <- fluidPage(

  # Application title
  titlePanel("Trial"),

  # Sidebar with a slider input for number of bins
  sidebarLayout(
    sidebarPanel(
      selectInput(
        inputId = "Weekday",
        label = "Choose a Weekday Type",
        choices = c(
          "Weekday Earnings" = "weekday_earn",
          "Weekend Earnings" = "weekend_earn",
          "Total Earnings" = "total_earn"
        ),
        selected = "total_earn"
      )
    ),

    # Show a plot of the generated distribution
    mainPanel(
      plotOutput("distPlot")
    )
  )
)

server <- function(input, output) {
  output$distPlot <- renderPlot({
    ggbetweenstats(
      data = total_data,
      x = type,
      y = !!rlang::sym(input$Weekday),
      type = "p",
      xlab = "Business Type",
      ylab = "Revenue",
      palette = "Set3",
      ggtheme = ggplot2::theme_gray()
    )
  })
}

# Run the application
shinyApp(ui = ui, server = server)

更多推荐

Rshiny,ggstatsplot

本文发布于:2023-04-18 10:47:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/hyzx/0731c14222a287dadb67d1f1c9159e3a.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Rshiny   ggstatsplot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!