Search code examples
rflextable

How can I remove a row from a flextable?


Given a flextable object how can I remove a row from it? For the below example the question more specifically is: How can I turn flexiris_six into flexiris_five without having to use different raw data?

library(flextable) # version 0.9.2

flexiris_six <- flextable(head(iris))
flexiris_five <- flextable(head(iris, 5))

Solution

  • There is the function delete_rows in flextable for that. Just try this:

    library(flextable) # version 0.9.4
    
    flexiris_six <- flextable(head(iris))
    
    flexiris_five <- flexiris_six %>%
      delete_rows(i = 6, part = "body")