R shiny table 没有填充的输出
R shiny table output with no padding
我正在尝试制作一个应用程序,其中某些 tables 没有填充。
server <- function(input, output) {
url = c("http://lorempixel.com/output/animals-q-c-480-480-7.jpg",
"http://lorempixel.com/output/animals-q-c-480-480-1.jpg",
"http://lorempixel.com/output/animals-q-c-480-480-8.jpg",
"http://lorempixel.com/output/animals-q-c-480-480-6.jpg"
)
image <- paste0( '<img src="',url,'" width=WIDTH></img>')
big.image <- gsub("WIDTH", "200px", image)
small.image <- gsub("WIDTH", "100px", image)
big.df <- data.frame(col1 = c(big.image[1], "Lorem", big.image[2], "Ipsum"),
col2 = c(big.image[3], "Dolor", big.image[4], "Sit"))
small.df <- data.frame(col1 = c(small.image[1], "Lorem", small.image[2], "Ipsum"),
col2 = c(small.image[3], "Dolor", small.image[4], "Sit"))
output$bigtable <- renderTable(big.df,
sanitize.text.function = function(x) x,
align='c',
colnames=F
)
output$smalltable <- renderTable(small.df,
sanitize.text.function = function(x) x,
align='c',
colnames=F
)
}
ui <- fluidPage(
mainPanel(tableOutput("bigtable"),
tableOutput("smalltable")
)
)
以上代码创建了一个包含 table 大图像和 table 小图像的应用。我希望大图像的 table 保持其当前间距,而小图像的 table 不具有间距。
ui <- fluidPage(
tags$head(
tags$style(HTML(
"
.table.shiny-table > thead > tr > th,
.table.shiny-table > tbody > tr > th,
.table.shiny-table > tfoot > tr > th,
.table.shiny-table > thead > tr > td,
.table.shiny-table > tbody > tr > td,
.table.shiny-table > tfoot > tr > td {
padding:0px;
}"))),
mainPanel(tableOutput("bigtable"),
tableOutput("smalltable")
)
)
上面的代码会让所有的table都没有间距,但是我只想让第二个没有间距。我该如何解决?
您可以用自己的 ID 调用第二个 table :
ui <- fluidPage(
tags$head(
tags$style(HTML(
"
#smalltable table > thead > tr > th,
#smalltable table > tbody > tr > th,
#smalltable table > tfoot > tr > th,
#smalltable table > thead > tr > td,
#smalltable table > tbody > tr > td,
#smalltable table > tfoot > tr > td {
padding:0px;
}"))),
mainPanel(tableOutput("bigtable"),
tableOutput("smalltable")
)
)
我正在尝试制作一个应用程序,其中某些 tables 没有填充。
server <- function(input, output) {
url = c("http://lorempixel.com/output/animals-q-c-480-480-7.jpg",
"http://lorempixel.com/output/animals-q-c-480-480-1.jpg",
"http://lorempixel.com/output/animals-q-c-480-480-8.jpg",
"http://lorempixel.com/output/animals-q-c-480-480-6.jpg"
)
image <- paste0( '<img src="',url,'" width=WIDTH></img>')
big.image <- gsub("WIDTH", "200px", image)
small.image <- gsub("WIDTH", "100px", image)
big.df <- data.frame(col1 = c(big.image[1], "Lorem", big.image[2], "Ipsum"),
col2 = c(big.image[3], "Dolor", big.image[4], "Sit"))
small.df <- data.frame(col1 = c(small.image[1], "Lorem", small.image[2], "Ipsum"),
col2 = c(small.image[3], "Dolor", small.image[4], "Sit"))
output$bigtable <- renderTable(big.df,
sanitize.text.function = function(x) x,
align='c',
colnames=F
)
output$smalltable <- renderTable(small.df,
sanitize.text.function = function(x) x,
align='c',
colnames=F
)
}
ui <- fluidPage(
mainPanel(tableOutput("bigtable"),
tableOutput("smalltable")
)
)
以上代码创建了一个包含 table 大图像和 table 小图像的应用。我希望大图像的 table 保持其当前间距,而小图像的 table 不具有间距。
ui <- fluidPage(
tags$head(
tags$style(HTML(
"
.table.shiny-table > thead > tr > th,
.table.shiny-table > tbody > tr > th,
.table.shiny-table > tfoot > tr > th,
.table.shiny-table > thead > tr > td,
.table.shiny-table > tbody > tr > td,
.table.shiny-table > tfoot > tr > td {
padding:0px;
}"))),
mainPanel(tableOutput("bigtable"),
tableOutput("smalltable")
)
)
上面的代码会让所有的table都没有间距,但是我只想让第二个没有间距。我该如何解决?
您可以用自己的 ID 调用第二个 table :
ui <- fluidPage(
tags$head(
tags$style(HTML(
"
#smalltable table > thead > tr > th,
#smalltable table > tbody > tr > th,
#smalltable table > tfoot > tr > th,
#smalltable table > thead > tr > td,
#smalltable table > tbody > tr > td,
#smalltable table > tfoot > tr > td {
padding:0px;
}"))),
mainPanel(tableOutput("bigtable"),
tableOutput("smalltable")
)
)