R shows this: Warning: Error in : pandoc document conversion failed with error 1 [No stack trace available]
output: 
  word_document:
    fig_caption: yes
    toc: true
    toc_depth: 2
    reference_docx: headingfive.docx
R shows this: Warning: Error in : pandoc document conversion failed with error 1 [No stack trace available]
output: 
  word_document:
    fig_caption: yes
    toc: true
    toc_depth: 2
    reference_docx: headingfive.docx
It should be fig_caption: true, not fig_caption: yes.
---
output: 
  word_document:
    fig_caption: true
    toc: true
    toc_depth: 2
    reference_docx: headingfive.docx
---  
The aruments that word_document accepts can be seen by checking ?rmarkdown::word_document. This help page says that fig_caption is logical.
EDIT(based on your comment): It seems that the flie "headingfive.docx" does not exist or you're in the wrong directory.
If you dont have the file yet you can check out these two links to see how its created:
https://www.r-bloggers.com/r-markdown-how-to-insert-page-breaks-in-a-ms-word-document/
How to add a page break in word document generated by RStudio & markdown
Finally youll have to make sure that the file "headingfive.docx" is in R's working directory(at least that's where it needs to be on Ubuntu).