这是我闪亮的应用程序。
我在表面板下创建了一个新的表面板。
我没有使用像br()和hr()这样的命令,但是它们之间存在差距。
有没有办法缩小或消除两者之间的差距?
发布于 2022-09-28 18:31:54
猜测使用的库和样式,下面是一个不同布局组合的示例(navbar +侧栏+选项卡、navbar +选项卡、navbar + navbar)。
您的例子似乎是嵌套的Navbar,这可能不是最好的方法,但它可以工作。注意内联样式:style='margin-top: -21px'
#install.packages("shinythemes")
#https://shiny.rstudio.com/articles/tabsets.html
#https://rstudio.github.io/shinythemes/
library(shiny)
library(shinythemes)
# Define UI for random distribution app ----
ui <- navbarPage(
theme = shinytheme("flatly"),
"CHIP",
tabPanel("Plot",
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
radioButtons(
"dist",
"Distribution type:",
c(
"Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm",
"Exponential" = "exp"
)
),
br(),
sliderInput(
"n",
"Number of observations:",
value = 500,
min = 1,
max = 1000
)
),
mainPanel(tabsetPanel(
type = "tabs",
tabPanel("SubA1", plotOutput("plot")),
tabPanel("SubA2", tags$p("In subA2")),
tabPanel("SubA3", tags$p("In subA3"))
))
)),
tabPanel(
"SubTabs",
tabsetPanel(
type = "tabs",
tabPanel("SubB1", tags$p("In subB1")),
tabPanel("SubB2", tags$p("In subB2")),
tabPanel("SubB3", tags$p("In subB3"))
)
),
tabPanel("SubNav", style='margin-top: -21px',
navbarPage("SubNav",
tabPanel("SubNav1", tags$p("In SubNav1")),
tabPanel("SubNav2", tags$p("In SubNav2")),
tabPanel("SubNav3", tags$p("In SubNav3"))
)
)
)
server <- function(input, output) {
d <- reactive({
dist <- switch(
input$dist,
norm = rnorm,
unif = runif,
lnorm = rlnorm,
exp = rexp,
rnorm
)
dist(input$n)
})
output$plot <- renderPlot({
dist <- input$dist
n <- input$n
hist(
d(),
main = paste("r", dist, "(", n, ")", sep = ""),
col = "#75AADB",
border = "white"
)
})
}
shinyApp(ui, server)
https://stackoverflow.com/questions/73875300
复制相似问题