使用officer软件包将ggvis散点图保存到PowerPoint幻灯片中

使用officer软件包将ggvis散点图保存到PowerPoint幻灯片中,r,shiny,powerpoint,officer,R,Shiny,Powerpoint,Officer,这是此处问题的后续问题: 我使用ggvis创建了一个交互式散点图。现在我想把它粘贴到PowerPoint幻灯片上。我正试图使用R中的“官员”包来实现这一点 然而,当我点击应用程序上的下载按钮时,我得到的只是应用程序的html输出,而不是PowerPoint幻灯片中的绘图。不确定问题是什么,请有人告诉我如何将此情节保存到PowerPoint幻灯片中(最好使用“官员”软件包,但任何其他功能或软件包也可以) 这是密码 library(shiny) library(data.table) librar

这是此处问题的后续问题:

我使用ggvis创建了一个交互式散点图。现在我想把它粘贴到PowerPoint幻灯片上。我正试图使用R中的“官员”包来实现这一点

然而,当我点击应用程序上的下载按钮时,我得到的只是应用程序的html输出,而不是PowerPoint幻灯片中的绘图。不确定问题是什么,请有人告诉我如何将此情节保存到PowerPoint幻灯片中(最好使用“官员”软件包,但任何其他功能或软件包也可以)

这是密码

library(shiny)
library(data.table)
library(DT)
library(ggvis)
library(officer)

# Define UI for application 
ui <- fluidPage(

    # Application title
    titlePanel("App"),

    sidebarLayout(
        sidebarPanel(
            fileInput(inputId = "inputCrossTab"
                      , label = "Select the input sheet"
                      , multiple = FALSE
                      , accept = c('.csv')
                      )
        ),

        # Show a table and plot 
        mainPanel(
           tabsetPanel(id = "tabset"
                       , type = 'pills'
                       , tabPanel(  title = "Table"
                                  , DT::dataTableOutput('table')
                                  )
                       , tabPanel(  title = "Charts"
                                  , ggvisOutput("plot")
                                  , downloadButton("down",label = "Download")
                                  )
               
           )
        )
    )
)

# Define server logic required 
server <- function(input, output) {
    
    # Import csv data as a reactive
    dat <- reactive({

        req(input$inputCrossTab$datapath)
        data.table::fread(  file   = input$inputCrossTab$datapath
                          , header = TRUE
                          )

    })
    
    
        

    
    # Render imported data as table
    output$table <- DT::renderDataTable({
        dat()
    })
    
    # Plot the table as a scatter plot
    output$plot <- reactive({
        dat()%>%
            ggvis::ggvis(~Total.x,~Total.y)%>%
            layer_points(fill:="red") %>%
            bind_shiny("plot")

    })
    
    # Trying a reactive object to pass on to read_pptx() function
    # which will paste the same plot as above to a PowerPoint file
    plotnew <- reactive({
      dat()%>%
        ggvis::ggvis(~Total.x,~Total.y)%>%
        layer_points(fill:="red") %>%
        bind_shiny("plotn")
      
    })
    
    
    
    # Download Handler to download the plot into a PowerPOint slide
    output$down <- downloadHandler(
      filename = "plot.pptx"
      
      , content = function(file){
        
        read_pptx() %>% 
          add_slide(layout = "Title and Content", master = "Office Theme") %>% 
          ph_with(value = plotnew(), location = ph_location_type(type = "body")) %>% 
          print(target = file)
          
      }
    )
    
    
    
}

# Run the application 
shinyApp(ui = ui, server = server)

X1,Total.x,Total.y
ncksncnxzc,0.8338719625,0.0163952762
xsmkslaxmkaslx,0.5867098735,0.2033673932
njasdnsa,0.3586965341,0.8281010715
sadlasdl;,0.060212096,0.1735624054
nsakksad,0.7281606887,0.3851430044