매우 간단한 문제가 있습니다. 조건부로 특정 셀에 색을 넣으려고합니다. shiny
renderTable
. 어떤 이유로 아래의 방법은 한 셀 오른쪽으로 착색되고,뿐만 아니라 하나 개의 컬럼을 통해 행의 셀 추진 :Shiny Rendertable의 셀 색칠
test <- data.frame(test1 = c(1:3), test2 = c(4:6))
test[test$test1 == 1, "test1"] <- '<td style="background-color:red">'
library(shiny)
ui <- shinyUI(fluidPage(
tableOutput("tt")
)
)
server <- shinyServer(function(input, output) {
output$tt <- renderTable({
test
}, sanitize.text.function = function(x) x)
})
shinyApp(ui = ui, server = server)
이 버그? HTML 출력을 검사했을 때 빈 <td> </td>
셀을 남기고 새로운 <td style="background-color:red">
을 생성한다는 것을 알았습니다. 나는 또한 시도 :
test[test$test1 == 1, "test1"] <- '<td bgcolor="#FF0000">1</td>'
이 다른 스타일 작동 :
이 작업이 너무 간단하다 : 나는 같은 더 복잡한 솔루션을 피하기 위해 노력하고
test[test$test1 == 1, "test1"] <- "<strong>1</strong>"
? 정말 고맙습니다.
오직 renderTable 만 사용하고 싶습니까? HtmlTable 또는 DT 일 수 있습니까? – Batanichek
@Batanichek 간단하게하기 위해 renderTable을 고수하고 싶습니다. 할 수 없다면 다른 함수와 패키지를 사용할 수 있습니다 (DT는 테이블을 찾는 방법이므로 어쨌든 배워야합니다). – Tunn