r-shiny_output比较结果为html格式



想要编写一个应用程序,使用闪亮的和comparedf包动态比较xlsx文件的不同版本。

以html格式输出比较结果时出现问题。

如何修复?是否可以使用htmlTable包输出html?

library(shiny)
library(compareDF)
library(htmlTable)
ui <- navbarPage("Compare_app",
tabPanel("Compare relults",
sidebarLayout(
sidebarPanel(
fileInput(inputId = "old_file", 
label = "Chose old file", 
accept = c(".xlsx")),
fileInput(inputId = "new_file", 
label = "Chose new file", 
accept = c(".xlsx")),
selectInput(inputId = "group_cols",
label = "Group by:",
choices = "",
selected = NULL,
multiple = TRUE)
),
mainPanel(
mainPanel(
htmlOutput(outputId = "compare_html")
) 
)
)
)
)
server <- function(input, output, session) {
old_file <- reactive({
old_file_tmp <- read_excel(req(input$old_file$datapath), col_names = TRUE)
}) 
new_file <- reactive({
old_file_tmp <- read_excel(req(input$new_file$datapath), col_names = TRUE)
}) 
observeEvent(old_file(), {
updateSelectInput(session, "group_cols", choices = names(old_file()))
})
output$compare_html <- renderUI({
vec <- unlist(strsplit(input$group_cols, ","))
compare_result_tmp <- compareDF::compare_df(df_new = new_file(), df_old = old_file(), group_col = vec)
compare_html <- compare_result_tmp$html_output
})
)
# Run the application
shinyApp(ui = ui, server = server)

这可以通过使用本机闪亮命令-来简单地实现

compare_html <- shiny::HTML(compare_result_tmp$html_output)

这应该以预期格式输出

相关内容

  • 没有找到相关文章

最新更新