no word report creation with R & Shiny (R studio)
<p>I created a R shiny application for stats analyses. I'd like that app allowed users to download a word report. I use the code on the shiny website gallery - <a href="http://shiny.rstudio.com/gallery/download-knitr-reports.html" rel="nofollow">http://shiny.rstudio.com/gallery/download-knitr-reports.html</a>.</p>

<p>Server</p>

<pre><code>shinyServer(function(input, output) {

  regFormula &lt;- reactive({
    as.formula(paste('mpg ~', input$x))
  })

  output$regPlot &lt;- renderPlot({
    par(mar = c(4, 4, .1, .1))
    plot(regFormula(), data = mtcars, pch = 19)
  })

  output$downloadReport &lt;- downloadHandler(
    filename = function() {
      paste('my-report', sep = '.', switch(
        input$format, PDF = 'pdf', HTML = 'html', Word = 'docx'
      ))
    },

    content = function(file) {
      src &lt;- normalizePath('report.Rmd')

      # temporarily switch to the temp dir, in case you do not have write
      # permission to the current working directory
      owd &lt;- setwd(tempdir())
      on.exit(setwd(owd))
      file.copy(src, 'report.Rmd')

      library(rmarkdown)
      out &lt;- render('report.Rmd', switch(
        input$format,
        PDF = pdf_document(), HTML = html_document(), Word = word_document()
      ))
      file.rename(out, file)
    }
  )

})
</code></pre>

<p>UI</p>

<pre><code>library(shiny)

shinyUI(fluidPage(
  title = 'Download a PDF report',
  sidebarLayout(
    sidebarPanel(
      helpText(),
      selectInput('x', 'Build a regression model of mpg against:',
                  choices = names(mtcars)[-1]),
      radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'),
                   inline = TRUE),
      downloadButton('downloadReport')
    ),
    mainPanel(
      plotOutput('regPlot')
    )
  )
))
</code></pre>

<p>It works fine and I can download the report on the  web  app. I use the proposed code in R studio on a OS X computer and it works fine too. I try to do the same with R studio on a win 7 computer but it doesn't works, the report (html, pdf or docx) is not created whereas the apps works fine.</p>

<p>Can someone help me ?</p>

<p>Ari</p>