rcolorsflextable

Colour body of flextable


I am piping data into the following in the hope to put a blue table around my data where am I going wrong?

 |> 
 flextable::flextable() |> 
 colors(color = 'blue',part = "body")
 

I get the following error

Error in colors(flextable::flextable(filter(select(EPR, region, organisation), : unused arguments (colors = "blue", part = "body")


Solution

  • Either use flextable::bg() instead of colors(), and replace argument color with bg (~background) to change the background colour,

    library(flextable)
    head(datasets::CO2) |>
      flextable() |>
      bg(bg = 'blue', part = "body")
    

    or do

    library(flextable)
    head(datasets::CO2) |>
      flextable() |>
      color(color = 'blue', part = "body")
    

    to change the text colour of the body's text.