Printing of visualizations on same file PDF new pages in R

Below snippet, is about a process of putting several R result visualizations in a pdf file. The few visualizations are pltBestSellingProducts, pltTreemap and wordCloud. Each using rendering method is renderPlot, renderPlot and renderWordcloud2 respectively. The problem is. When I download the pdf files, only vals$BestSellingProducts can be seen, while vals$wordCloud and vals$Treemap, can't be seen in the said PDF. I don't know what's the issue because those visualizations did not return NULL(that means something is stored inside but my extraction method to the pdf, might be wrong). Can someone give me a hint on it? Also I have try searching for R Markdown implementation, but I want something which can be implement easier on the go without considering about the quality.

vals <- reactiveValues({
    BestSellingProducts = NULL,
    wordCloud = NULL,
    Treemap = NULL

pdf_file <- tempfile(fileext = ".pdf")

output$pltBestSellingProducts <- renderPlot({
    table_BestSellingProducts <- OPT_csv_data() %>%
      group_by(product_id) %>%
      summarize(count=n()) %>%
      top_n(10,wt=count) %>%
      left_join(select(products_csv_data(),product_id,product_name),by="product_id") %>%
    BestSellingProd <- table_BestSellingProducts %>%
      ggplot(aes(x=reorder(product_name,count), y=count))+
      geom_bar(position="dodge", stat="identity",fill="#F9CF59")+
      coord_flip() +
      theme_classic() +
      labs(title ="", y="Number of units sold", x="")
    vals$BestSellingProducts <- BestSellingProd + scale_y_continuous(labels=human_num)

output$pltTreemap <- renderPlot({
    tmp <- products_csv_data() %>%
      group_by(department_id,aisle_id) %>%
    tmp <- tmp %>% left_join(departments_csv_data(),by="department_id")
    tmp <- tmp %>% left_join(aisles_csv_data(),by="aisle_id")
    tmp2 <- OPT_csv_data() %>%
      group_by(product_id) %>%
      summarize(count=n()) %>%
      left_join(products_csv_data(),"product_id") %>%
      ungroup() %>%
      group_by(department_id,aisle_id) %>%
      summarize(sumcount=sum(count)) %>%
      left_join(tmp,by=c("department_id","aisle_id")) %>%

output$wordCloud <- renderWordcloud2({
    vals$wordCloud<-wordcloud2(Top_text(), size = 1, shape = "hexagon")

I am expecting that all visualizations, can be printed and showed at the pdf files. Instead of the current problem where, only vals$BestSellingProducts can be seen while the others are missing.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.