我有这个shiny 的仪表板,我想将文本稍微向右移动一点,以便从与单选按钮相同的位置开始.

library(shiny)
library(shinydashboard)

# Define UI
ui <- dashboardPage(
  dashboardHeader(title = "My Shiny Dashboard"),
  dashboardSidebar(
    radioButtons("d23", "Display on:",
                 choices = c("2D","3D"),
                 selected = "2D"),
    # Place the uiOutput inside the sidebar
    uiOutput("minmax")
  ),
  dashboardBody()
)

# Define server logic
server <- function(input, output) {
  output$minmax <- renderUI({
    # Use renderText inside uiOutput
    textOutput("minmax_text")
  })
  
  output$minmax_text <- renderText({
    
    paste("Minimum for Selected Topics:", "23",
          "Maximum for Selected Topics:", "34"
    )
  })
}

# Run the application
shinyApp(ui = ui, server = server)

推荐答案

通过类shiny-input-container设置单选按钮组的填充.因此,将textOutput与单选按钮对齐的一种 Select 是将其包装在具有相同类的div中:

server <- function(input, output) {
  output$minmax <- renderUI({
    tags$div(
      class = "shiny-input-container",
      textOutput("minmax_text")  
    )
  })

  output$minmax_text <- renderText({
    paste(
      "Minimum for Selected Topics:", "23",
      "Maximum for Selected Topics:", "34"
    )
  })
}

enter image description here

R相关问答推荐

如何将具有重复名称的收件箱合并到R中的另一列中,而结果不同?

按R中的组查找相邻列的行累积和的最大值

在(g)子中使用asserable字符

如何删除R中除某些特定名称外的所有字符串?

derrr mutate case_when grepl不能在R中正确返回值

如何将旋转后的NetCDF转换回正常的纬度/经度网格,并使用R?

将多列合并为单独的名称—值对

如何使用ggplot对堆叠条形图进行嵌套排序?

按多列统计频次

R:用GGPLATE,如何在两个独立的变量中制作不同形状的散点图?

如何构建一个for循环来循环处理动物ID?

自定义交互作用图的标签

对R中的列表列执行ROW Mean操作

R:如何在数据集中使用Apply

Data.table::Shift type=允许扩展数据(&Q;LAG&Q;)

基于R中的引用将向量值替换为数据框列的值

以R表示的NaN值的IS.NA状态

使用显式二元谓词子集化sfc对象时出错

将y轴格式更改为R中的百分比

Data.table条件合并