【问题标题】:Shiny App Error: Aesthetics must be either length 1 or the same as the data (1): xShiny App 错误:美学长度必须为 1 或与数据 (1) 相同:x
【发布时间】:2022-08-20 00:32:29
【问题描述】:

我正在自学 r,我正在尝试在 NBA 数据上创建一个闪亮的应用程序,我正在询问球员的姓名和输入的统计数据。

 textInput(\"name\", \"Name\", value = \"Giannis Antetokounmpo\"),
      
 selectInput(\"stat\", \"Stat\", choices = list(\"Points Per Game\" = \"PTS\",
                                                 \"Rebounds Per Game\" = \"TRB\",
                                                 \"Assits Per Game\" = \"AST\",
                                                 \"Steals Per Game\" = \"STL\",
                                                 \"Blocks Per Game\" = \"BLK\"),
                                                  selected = \"PTS\"),

尝试创建散点图时,我收到“美学必须是长度 1 或与数据相同”的错误

    NBA_abv %>% 
      filter(Player == input$name) %>%
      ggplot(aes(x = Year, y = input$stat)) + geom_point() + geom_line()

Here is the dataset i\'m using

标签: r ggplot2 shiny


【解决方案1】:

我想我以前遇到过这个错误。如果我没记错的话,你需要使用aes_string

    NBA_abv %>% 
      filter(Player == input$name) %>%
      ggplot(aes_string(x = Year, y = input$stat)) + geom_point() + geom_line()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-17
    • 2016-10-13
    • 2017-11-04
    • 1970-01-01
    • 2016-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多