Flextable output in RMarkDown

rmarkdown
rstudio

#1

I'm trying to figure out why this particular example of a flextable in R Markdown isn't working. Whenever I run the code it generates the document, however, wherever the reference eg r myTable to the flextable is gets replaced by 20 or so blank pages in the docx output.

Here's a modified version of the code:

Issue <- c("Taxable Activity", "Valid tax invoices", "GST claimed where no GST charged", "Zero Rated input tax", "Duplicate payments")

 Observations_and_findings <- c(taxableText, validInvoiceText, incorrectClaimText, zeroInputText, duplicateText)
  tableFrame <- data.frame(Issue, Observations_and_findings, check.rows =  FALSE, check.names = TRUE, fix.empty.names = TRUE)

  library(officer)
  library(flextable)

  inputFT <- regulartable(tableFrame, col_keys = c("Issue", "Observations_and_findings"))
  inputFT <- autofit(inputFT)

  inputFT <- empty_blanks(inputFT)
  inputFT <- theme_vanilla(inputFT)
  inputFT <- color(inputFT, color = "white", part = "header")
  inputFT <- bg(inputFT, bg = "darkblue", part = "header")
  inputFT <- padding(inputFT, padding = 4, part= "all")
  inputFT <- align(inputFT, align = "left", part = "header")
  inputFT

(https://pasteboard.co/Hv5hAAz.png)

Whenever I add a `r inputFT` into the text it generates at least 20 blank pages within the docx output.

The thing that confuses me is here is another flextable I have in the same MarkDown file that has no issues at all

Summary_Type <- c("Row One", "Row Two")
  GST_returns_as_filed <- c(0)
  GST_data_extracted <- c(0)
  Difference <- c(0)

  tableFrame <- data.frame(Summary_Type, GST_returns_as_filed, GST_data_extracted, Difference, check.rows =  FALSE, check.names = TRUE, fix.empty.names = TRUE)

  myft <- regulartable(tableFrame, col_keys = c("Summary_Type", "GST_returns_as_filed", "GST_data_extracted", "Difference")) 

  myft <- autofit(myft)
  myft <- empty_blanks(myft)

  myft <- add_footer(myft, GST_data_extracted = "Total", Difference = "$0.000")

  myft <- color(myft, color = "red", part = "footer")
  myft <- theme_vanilla(myft) 

  myft <- padding(myft, padding = 4, part= "all")

  myft <- align(myft, align = "left", part = "header")

  myft

(https://pasteboard.co/Hv5hWzc.png)


#2

Hi Cam, welcome to community!

Any way you could ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

The current code-snippet refers to objects that aren't defined.