Download a PowerPoint template from my GitHub using R

I am trying to develop a function that will download an .rmd and .pptx files to create a consistent visual identity. I have uploaded a .pptx file to use as a reference doc however when I download it using download.file() I get an error saying there is a problem with the content and it can't be read. The Github is here:

EDIT: I tried the same with a Word doc and same error.

And my code is :

download.file("https://github.com/grousell/hwdsb/raw/master/templates/hwdsb_ppt_template.pptx",
                destfile = "ppt_template.pptx"
  )

By default, downlaod.files() assumes it's downloading text and saves it as such. For a Powerpoint file, you want it saved as-is, so you need to indicate it's a binary format:

download.file("https://github.com/grousell/hwdsb/raw/master/templates/hwdsb_ppt_template.pptx",
              destfile = "ppt_template.pptx",
              mode = "wb"
)

Same for a Word doc, however as an Rmd file is indeed text, you shouldn't need that option.

This topic was automatically closed 7 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.