0
我想要製作一個應用程序,其中一些表格沒有填充。R沒有填充的閃亮表格輸出
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")
)
)
上面的代碼創建了一個應用程序,其中包含大圖像和小圖像表。我希望大圖的表格保持當前的間距,而小圖的表格不要有間距。
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")
)
)
上面的代碼將使所有的表沒有間距,但我只希望第二個沒有間距。我該如何解決這個問題?
的感謝!工作! – Katom