1

我正在寻找在我的 ui.R 中放入相同的 tabPanel :1 highchartOutput 和 1 wordcloud2Output 但只有我的 wordcloud2Output 打印。我尝试隔离我的 highchartOutput,没问题它在同一个 tabPanel 中没有 wordcloud2Output 的情况下运行。

例子:

  ui <- fluidPage(
    
    navbarPage(
      "Try put Wordcloud2 and Highcharter in the same page",
      id = "main_navbar",
      
      tabPanel(
        "MytabPanel",
        fluidRow(
          width = 12,
          column(width = 7, wordcloud2Output("tdb1_wordcloud", height = 620)),
          column(width = 5, highchartOutput("tdb1_myplot", height = 620)))) ))
  
#_______________________
  
  server <- function(input, output, session) {
    
    output$tdb1_wordcloud <- renderWordcloud2({
      wordcloud2(data.table(word = c("email","phone","visit"), freq = c(10,15,4))) })
    
    output$tdb1_myplot <- renderHighchart({
      x <- c(rnorm(10000), rnorm(1000, 4, 0.5))
      hchart(x, name = "data") }) }

#_______________________
  
  runApp(list(ui = ui, server = server),launch.browser = TRUE)

使用 wordcloud2Output + highchartOutput 进行闪亮渲染

如果我将我的“wordcloud2Output”放在评论中,我的 highchartOutput 运行

仅使用 highchartOutput 进行闪亮渲染

谢谢你的帮助!

4

1 回答 1

0

使用uiOutput()似乎可以解决问题。

library(shiny)
library(highcharter)
library(wordcloud2)
library(data.table)

ui <- fluidPage(
    
    navbarPage(
        "Try put Wordcloud2 and Highcharter in the same page",
        id = "main_navbar",
        
        tabPanel(
            "MytabPanel",
            fluidRow(
                width = 12,
                column(width = 7, wordcloud2Output("tdb1_wordcloud", height = 620)),
                column(width = 5, uiOutput('hc')))) ))
    

#_______________________

server <- function(input, output, session) {
    
    output$hc <- renderUI({highchartOutput("tdb1_myplot", height = 600)})
    
    output$tdb1_wordcloud <- renderWordcloud2({
        wordcloud2(data.table(word = c("email","phone","visit"), freq = c(10,15,4))) })
    
    output$tdb1_myplot <- renderHighchart({
        x <- c(rnorm(10000), rnorm(1000, 4, 0.5))
        hchart(x, name = "data") })
}

#_______________________

runApp(list(ui = ui, server = server),launch.browser = TRUE)
于 2021-06-17T01:59:54.880 回答