闪亮 - 一行中有两个selectInput和一个复选框

时间:2016-05-08 06:35:13

标签: r shiny

如何在一行中创建2个selectInput和一个复选框,显示将如下所示:

x轴:----- y轴:-------检查

代码是: 用户界面:

library(shiny)
shinyUI(fluidPage(
  titlePanel("Shiny"),
  sidebarLayout(
    sidebarPanel(

    ),
    mainPanel(

      uiOutput("scatcoefgwr")
    )
  )
))

服务器:

shinyServer(function(input, output) {

  output$scatcoefgwr <- renderUI({

    list(

      selectInput("axisx", "x axis:",choices = c("1","2","3")),
      selectInput("axisy", "y axis:",choices = c("1","2","3")),
      checkboxInput("scatterD3_ellipsesgwr", "check", value = FALSE)
    )
  })

}) 

1 个答案:

答案 0 :(得分:2)

这是使用列

的一种方法
#ui.R
library(shiny)
shinyUI(fluidPage(
  titlePanel("Shiny"),
  fluidRow(
    column(width=2,uiOutput("one")),   
    column(width=2,uiOutput("two")),
    column(width=2,uiOutput("three"))
  )
))

根据需要更改宽度。

#server.R
shinyServer(function(input, output) { 
  output$one <- renderUI({
    list(
      selectInput("axisx", "x axis:",choices = c("1","2","3"))
    )
  })
  output$two <- renderUI({
    list(
      selectInput("axisy", "y axis:",choices = c("1","2","3"))
    )
  })
  output$three <- renderUI({
    list(
      checkboxInput("scatterD3_ellipsesgwr", "check", value = FALSE)
    )
  })
})