如何在R Shiny中更改wordcloud的大小以不剪切图像?

时间:2018-07-23 13:30:12

标签: r shiny

如何更改R中闪亮的wordcloud的大小,以免剪切图像?

我使用了png()函数,但没有得到结果:

enter image description here

output$plot2 <- renderPlot({

    terms2 <- reactive({
      # Change when the "update" button is pressed...
      input$update

      data2 <- input$texto1

      # ...but not for anything else
      isolate({
        withProgress({
          setProgress(message = "Processing corpus...")
          getTermMatrix2(data2)

        })
      })
    })

    v2 <- terms2()

    wordcloud_rep2(names(v2), v2, scale=c(4,0.5),
                  min.freq = 1, max.words=20,
                  colors=brewer.pal(8, "Dark2"))
  })

1 个答案:

答案 0 :(得分:0)

使用wordcloud2代替wordcloud。
它的基本需求是两列单词和频率来呈现单词云, 它也有自己的renderoutput和renderwordcloud。 我附上了例子看看。

this is how your data should look like:

   words   freq
   oil     85
   said    73
   prices  48

wordcloud2 link

   library(wordcloud2)
   library(shiny)
   library(shinydashboard)

 ui <- dashboardPage(
       dashboardHeader(),
         dashboardSidebar(),
           dashboardBody(
               wordcloud2Output('cloud')
            )
          ) 

    server <- function(input, output) {
       output$cloud <- renderWordcloud2({
        wordcloud2(demoFreq)
     })
    }

  shinyApp(ui, server)