Why can't I add this tibble to my docx?

I have this docx document who has a table

document <- read_docx('word.docx')
documento<-docx_summary(document)
document

And this tibble

table_result
# A tibble: 5 × 2
  hola  chau 
  <chr> <chr>
1 1     6    
2 2     7    
3 3     8    
4 4     9    
5 5     10  

Why can't I add this tibble to my docx document with this code?

table_result<-
  table_result %>%
  mutate(prueba= 10:14) %>%
  flextable()

document2<- 
  body_add_table(
    document,
    table_result, 
    style = 'Table Professional',
    header = T,
    alignment = 'center',
    first_column = T
  )
Error in block_table(x = value, header = header, properties = pt, alignment = alignment) : 
  is.data.frame(x) is not TRUE

I have not used any of these functions but I suspect that the flextable() function does not return a data frame and body_add_table needs a data frame for the second argument. What is the result of

class(table_result)

use body_add_flextable to add a flextable rather than a mere dataframe.

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