首页 > 解决方案 > Rshiny:在数据表中,我应该如何突出显示某些文本?

问题描述

我正在创建一个 R 闪亮的应用程序,当我使用浏览按钮输入一个 CSV 文件时,它现在显示一个数据表。我想强调几句话。在一个四列十行的 CSV 文件中,我想在主面板中突出显示第 4 列和第 9 行的值。应该如何在 R 中完成

我的代码:


library(shiny)

ui <- fluidPage(  
  
  fileInput("myfileinput", "Please choose a csv File", multiple = FALSE, accept = c("text/csv", "text/comma-separated-values,text/plain", ".csv")),
  
  
  
  tableOutput('mytable')
  
)

server <- function(input, output, session) {
  
  #Reactive to store loaded data
  reactives <- reactiveValues(
    
    mydata = NULL
    
  )
  
  #Observe file being selected
  observeEvent(input$myfileinput, {
    
    #Store loaded data in reactive
    reactives$mydata <- read.csv(file = input$myfileinput$datapath)
    
    
    
  })
  
  #Data table
  output$mytable <- renderTable({ 
    
    reactives$mydata
    
  })
  
}

shinyApp(ui = ui, server = server)

标签: rshiny

解决方案


推荐阅读