我有一个闪亮的应用程序,可以产生带有一些小部件的井板。
#ui.r
navbarPage(
"Application",
tabPanel("General",
sidebarLayout(
sidebarPanel(
),
mainPanel(
wellPanel(
h4("Format"),
fluidRow( # Width = sum of component columns
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
column(3,
h5("Booklet ID"),
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num3"))
),
column(
3,h5("Data"),
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num4"))
),
column(3,
uiOutput("c1"),
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num8")),
uiOutput("help1")),
column(
3,
uiOutput("c2"),
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num10")),
uiOutput("help3")
)
),
column(width = 12, fixedRow( # Width = sum of component columns fluidRow
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
column(
3,
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num5"))
),
column(
3,
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num7"))
),
column(
3,
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num9")),
uiOutput("help2")
),
column(
3,
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num11")),
uiOutput("help4")
)
)))
)
)
)
)
#server.r
library(shiny)
server <- function(input, output,session) {
output$num3<-renderUI({
textInput("nm3",
h6("Column"),
value = 1)
})
output$num4<-renderUI({
textInput("nm4",
h6("First Column"),
value = as.numeric(input$nm3)+input$nm5)
})
output$num5<-renderUI({
numericInput("nm5",
h6("Length"),
value = 2)
})
output$num7<-renderUI({
numericInput("nm7",
h6("Length Response"),
value = 1)
})
output$c1<-renderUI({
checkboxInput("ch1",
h5("Person ID"), value = FALSE)
})
output$num8<-renderUI({
if(input$ch1==T){
textInput("nm8",
h6("Column"),
value = 1)
}
else{
output$help1<-renderUI({
helpText("Click Person ID")
})
}
})
output$num9<-renderUI({
if(input$ch1==T){
numericInput("nm9",
h6("Length"),
value = 1)
}
else{
output$help2<-renderUI({
helpText("Click Person ID")
})
}
})
output$c2<-renderUI({
checkboxInput("ch2",
h5("Covariates"), value = FALSE)
})
output$num10<-renderUI({
if(input$ch2==T){
textInput("nm10",
h6("Column"),
value = 1)
}
else{
output$help3<-renderUI({
helpText("Click Covariates")
})
}
})
output$num11<-renderUI({
if(input$ch2==T){
numericInput("nm11",
h6("Length"),
value = 1)
}
else{
output$help4<-renderUI({
helpText("Click Covariates")
})
}
})
}
我希望在井面板中将所有内容都放在同一行中。问题是,正如您将在下面看到的,我可以部分实现这一目标。
我使用了div(style="display: inline-block;vertical-align:top; width: 150px;"
,但它似乎可以局部使用。
答案 0 :(得分:1)
更新:该操作无效,并以某种方式将第三行从面板中移出。这可能是由于CSS,if_else renderUI或其他原因造成的。不幸的是,我暂时不能投票否定自己……
您只需要将列包装在fixedRow()
中即可。
对于第二行,请尝试:
column(width = 12, fixedRow( # Width = sum of component columns
column(
3,
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num5"))
),
column(
3,
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num7"))
),
column(
3,
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num9")),
uiOutput("help2")
),
column(
3,
div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num11")),
uiOutput("help4")
)) # One ) for the column, one more for the fixed row. End the fluid row appropriately