plotly + shiny 错误:geom_col 需要以下缺失的美学:[32mx[39m 和 [32my[39m

问题描述 投票:0回答:1

我是 Shiny/shinydahsboard 的新手,正在从事一个项目以使其变得更好。我一直遇到 plotly 和 goem_bar 或 geom_col 图的问题。我得到的错误是美学缺失,即使它包含在 ggplot() 中。

我也曾尝试在 flexdashboard 中工作并遇到了类似的问题,我会得到错误

geom_col() requires the following missing aesthetics: x and y
,但在这两种情况下我都可以使用常规的非绘图图。

任何见解将不胜感激!谢谢!

数据

我在用

df %>% count(Loc)
等同于此结果用于测试目的:

df2 <- data.frame (Loc = c("Los Angeles", "New York City", 
"Seattle"),  n = c(337, 233, 304))

df2 <- as.tibble(df2)

代码

header <- dashboardHeader(title="Employee Dashboard")

sidebar <- dashboardSidebar()

body <- dashboardBody(
          fluidRow(
            box(
              plotlyOutput("loc_plot"))
      )
)


ui <- dashboardPage(header, sidebar, body)


server <- function(input, output, session) {


    output$loc_plot <- renderPlotly({
        loc_plotly <- df2 %>%    
          ggplot(aes(x=Loc, y=n)) +
          geom_col(fill= "#2171B5")
    
        ggplotly(loc_plotly)
    })
  
}

shinyApp(ui=ui, server=server)`

错误 enter image description here`

r shiny plotly shinydashboard
1个回答
0
投票

尴尬的是,将我的 plotly 包更新到最新版本解决了这个问题。 :)

© www.soinside.com 2019 - 2024. All rights reserved.