2016-12-06 5 views
0

일부 테이블에 패딩이없는 앱을 만들려고합니다.패딩이없는 반짝이는 테이블 출력

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") 
    ) 
) 

위 코드를 사용하면 모든 테이블에 공백이 없어지지만 두 번째 공백에는 공백이 없어야합니다. 이 문제를 어떻게 해결할 수 있습니까?

답변

0

당신은 자신의 ID로 두 번째 테이블을 호출 할 수 있습니다

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") 
    ) 
    ) 
+0

감사합니다! 그게 효과가! – Katom

관련 문제