您可以将一个类添加到Table
标签。在这种情况下,我添加了一个rightAlign
类给它。tabPanel("Table", tableOutput("table"), class = 'rightAlign')
然后,您可以以任何常用方式设置此选项卡的样式http://shiny.rstudio.com/articles/css.html http://shiny.rstudio.com/articles/css.html使用类似的东西.rightAlign{float:right;}
对于CSS。
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())
})
}
)
)