您可以向Table 选项卡添加一个类。在这种情况下,我添加了一个 rightAlign 类。 tabPanel("Table", tableOutput("table"), class = 'rightAlign') 然后,您可以使用 .rightAlign{float:right;} 之类的 CSS 以任何常用方式设置此选项卡的样式 http://shiny.rstudio.com/articles/css.html。
library(shiny)
runApp(list(
ui = fluidPage(
tags$head(tags$style(".rightAlign{float:right;}")),
titlePanel("Tabsets"),
sidebarLayout(
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("Plot", plotOutput("plot")),
tabPanel("Summary", verbatimTextOutput("summary")),
tabPanel("Table", tableOutput("table"), class = 'rightAlign')
)
)
)
)
, server = function(input, output) {
data <- 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(data(), main=paste('r', dist, '(', n, ')', sep=''))
})
output$summary <- renderPrint({
summary(data())
})
output$table <- renderTable({
data.frame(x=data())
})
}
)
)