0

this is a big problem for me as I need to have un-named column names inside my flextable in officer. This previously worked with the ReporteRs version. But so far haven't been able to do this, tried using the following code:

rename(` ` = col0)

When I run try and create a flextable using this column name I get the following error message: Error in flextable(a) : invalid col_keys, flextable support only syntactic names

data <- head(iris) %>%
  rename(` ` = Sepal.Length)
myft <- regulartable(data)
myft1<- flextable(data)

Note: the regulartable(data) works and the column name is blank. When trying to do this with a flextable however it doesn't work and errors

Is there anyway that I am able to do this with a flextable?

Many thanks in advance

Zuti
  • 85
  • 8
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Nov 28 '18 at 16:51
  • edited post - regular table works but flextable doesn't and i'd like it to work with flextable too – Zuti Nov 29 '18 at 10:24

1 Answers1

2

You don't need to modify your data.frame to customize the display. Having names like is risky IHMO. Read https://davidgohel.github.io/flextable/articles/layout.html#manage-headers-and-footers

library(flextable)
library(magrittr)
library(dplyr)

data <- head(iris)
myft <- regulartable(data) %>% 
  set_header_labels(Sepal.Length = " ")

myft1 <- flextable(data) %>% 
  set_header_labels(Sepal.Length = " ")

myft1
David Gohel
  • 9,180
  • 2
  • 16
  • 34