You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

R Shiny更换设备后出现Font Awesome gears图标不存在及widgetUserBox报错

R Shiny报错问题解决方案

1. could not find function "widgetUserBox"报错解决

  • 该函数不属于基础shinydashboard包,是扩展包shinydashboardPlus的专属功能,新系统未安装对应包或版本不兼容会触发该报错
  • 操作步骤:
    1. 安装稳定版扩展包:
      install.packages("shinydashboardPlus")
    2. 代码运行前加载对应包,或调用时补全命名空间:
      开头添加library(shinydashboardPlus),或者直接写shinydashboardPlus::widgetUserBox()调用
    3. 若最新版本仍不兼容,可安装旧项目常用的2.0.3适配版本:
      remotes::install_version("shinydashboardPlus", version = "2.0.3")

2. Font Awesome gears图标不存在报错解决

  • 最新版shiny/shinydashboard默认绑定Font Awesome 6.x版本,gears图标在更低版本中名称为cogs,图标名称和依赖的FA版本不匹配就会触发校验报错
  • 操作步骤:
    1. 调整代码中的图标名称:FA 5.x及以下版本将gears替换为cogs,FA 6.x及以上版本保留gears即可
    2. 不想修改图标名称的话,直接在调用图标时关闭校验:icon("gears", verify_fa = FALSE)

完整可运行测试代码

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    widgetUserBox(
      title = "Alexander Pierce",
      subtitle = "Founder & CEO",
      type = NULL,
      src = "https://adminlte.io/themes/AdminLTE/dist/img/user1-128x128.jpg",
      color = "aqua-active",
      closable = TRUE,
      "Some text here!",
      footer = "The footer here!"
    )
  )
)

server <- function(input, output) {}

shinyApp(ui, server)

内容的提问来源于stack exchange,提问作者NIrbhay Mathur

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 01:06:02