首页 > 解决方案 > RShiny:保存 htmlOutput 的 html 内容

问题描述

我开发了一个带有管理界面的闪亮应用程序。该界面允许统计学家导入数据并创建图表。我想保存要在用户页面上显示的 html 元素renderUI({HTML(content)})。在 rstudio 社区网站上提出了同样的问题:https ://community.rstudio.com/t/how-can-i-save-r-shiny-html-output-to-an-external-file/89415

例如在下面的例子中如何保存内容htmlOutput('content')

在此处输入图像描述

library(shiny)
library(datasets)
library(shinyjqui)

# Global variables 
n <- 200

# Define the UI
ui <- fluidPage(
  
  numericInput('n', 'Number of obs', n),
  selectInput("region", "Region:", 
              choices=colnames(WorldPhones)),
  br(),br(),
  
  htmlOutput('content')
)


# Define the server code
server <- function(input, output) {

output$content <- renderUI({
fluidRow(
      jqui_resizable(column(6, plotOutput('plot1'))),
      jqui_resizable(column(6, plotOutput('plot2')))
    )
})
  
output$plot1 <- renderPlot({
    hist(runif(input$n))
  })

output$plot2 <- renderPlot({
barplot(WorldPhones[,input$region]*1000, 
          main=input$region,
          ylab="Number of Telephones",
          xlab="Year")
})

}

shinyApp(ui = ui, server = server)

感谢你的回复

标签: htmlrshinyrshiny

解决方案


推荐阅读