微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么 RenderUI 从某些 Selectinput 选择中随机踢出错误?

如何解决为什么 RenderUI 从某些 Selectinput 选择中随机踢出错误?

我正在尝试根据用户从 selectinput 中的选择在 ui.r 中呈现一些动态文本,它适用于大多数名称,但列表中有一两个会引发错误

Warning: Error in FUN: argument is not a character vector
  99: lapply
  98: paste8
  97: HTML
  96: renderUI [/Users/spencepurnell/Documents/Shiny_apps/Ray_Lewis_Experiment/server.R#933]
  95: func
  82: origRenderFunc
  81: output$combine_compare_color
   1: runApp

鉴于该错误消息,我怀疑它与字符的解析有关,但它同样适用于列表中的其他名称,但有两个名称专门引发错误并级联。

这是我设置用户界面的方法

tabItem("profile_tab",fluidRow(
                             Box(
                               selectInput("profile_player_selection","Select Player to Profile",choices = as.list(ed_profile_names),selected = "Anthony Nelson")
                             ),Box(
                               selectInput("player_profile_comparison","Select Player to Compare",choices =  as.list(ed_profile_names_compare),selected = "Nick Bosa"))
                           ),fluidRow(
                             Box(title = uIoUtput("combine_status_color"),width = 6,collapsible = T,tableOutput("combine_page_table"),),Box(title = uIoUtput("combine_compare_color"),tableOutput("combine_page_comparison")
                                 )
                              )
                           ) 

这里是 server.r:

ed_color <- reactive({
      data_ed() %>% 
        dplyr::select(
          Name,"Height (in)","Weight (lbs)","40 Yard","Bench Press","Vert Leap (in)","broad Jump (in)",Shuttle,"Three Cone","Edge Combine score"
        ) %>%
        dplyr::filter(Name == input$profile_player_selection) 
        
      
    })
#> Error in reactive({: Could not find function "reactive"
    
  output$combine_status_color <- renderUI({
    
    if(ed_color()[,"Edge Combine score"] > 90 ) {
      a <- paste("<span style=color:#2DBF29>","ELITE Combine score")
    } 
    else if(ed_color()[,"Edge Combine score"] < 90 & ed_color()[,"Edge Combine score"] > 80 ) {
      a <- paste("<span style=color:#1955CE>","GOOD Combine score")
    } 
    else if(ed_color()[,"Edge Combine score"] < 80 & ed_color()[,"Edge Combine score"] > 70 ) {
      a <- paste("<span style=color:#FA8B05>","STANDARD Combine score")
    } 
    else if(ed_color()[,"Edge Combine score"] < 70 & ed_color()[,"Edge Combine score"] > 60 ) {
      a <- paste("<span style=color:#FA8B05>","AVERAGE Combine score")
    }
    else if(ed_color()[,"Edge Combine score"] < 60 & ed_color()[,"Edge Combine score"] > 50 ) {
      a <- paste("<span style=color:#FA8B05>","POOR Combine score")
    }
    else if(ed_color()[,"Edge Combine score"] < 50 & ed_color()[,"Edge Combine score"] > 40 ) {
      a <- paste("<span style=color:#FA8B05>","WORST Combine score")
    }
    
     HTML(a)
    
  })

您可以(希望)看到我正在尝试通过同一组变量过滤大型数据框,但更改了用户输入的名称。 RenderUI 和 if 语句旨在读取数据框中的某个分数并提供相应的文本。同样,大多数名称都有效,但只有少数名称会出错。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。