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
发布评论